{"id":32,"date":"2006-06-03T10:15:07","date_gmt":"2006-06-03T18:15:07","guid":{"rendered":"http:\/\/simplepie.org\/blog\/2006\/06\/03\/bypass-hotlink-blocking-when-displaying-a-feed-beta-2\/"},"modified":"2006-06-26T19:38:16","modified_gmt":"2006-06-27T03:38:16","slug":"bypass-hotlink-blocking-when-displaying-a-feed-beta-2","status":"publish","type":"post","link":"https:\/\/simplepie.org\/blog\/2006\/06\/03\/bypass-hotlink-blocking-when-displaying-a-feed-beta-2\/","title":{"rendered":"Bypass &#8220;hotlink blocking&#8221; when displaying a feed (Beta 2)"},"content":{"rendered":"<p class=\"subscribe\"><b>Requirements:<\/b> SimplePie 1.0 Beta 2<\/p>\n<div class=\"chunk noborder\">\nIn my quest for making a feed parser that is intelligent, simple, and graceful, one thing that has always bugged me about online feed readers is that some people disable the ability to hotlink images.<\/p>\n<p>Now, I understand why they do this, because I do it too.  You don&#8217;t want a bunch of your bandwidth sucked up by people who are stealing your images for their own nefarious purposes (mwah-hah-hah!).  Rather, you&#8217;d prefer to keep the images for <em>your readers who are reading your content<\/em>.  Well, that&#8217;s exactly what a feed parser is for, right?<\/p>\n<p>Desktop aggregators like <a href=\"http:\/\/www.feeddemon.com\">Feed Demon<\/a> and <a href=\"http:\/\/ranchero.com\/netnewswire\/\">NetNewsWire<\/a> are always able to just load up the images in context with the post that they&#8217;re reading, and it all makes sense.  The only reason why online feed readers have a problem is because the browsers that run them respect the hotlinking rules&mdash;even if the reasons don&#8217;t make sense for the context (like trying to apply laws about CD&#8217;s to MP3&#8217;s&mdash;although they&#8217;re related, they&#8217;re different, and the rules need to be modified for the new medium).<\/p>\n<p>So, we&#8217;ve decided to solve the problem in our latest release.  We&#8217;ve added functionality that allows you to bypass hotlink protection for feeds that you&#8217;re trying to read online.  But that isn&#8217;t what&#8217;s important.  What&#8217;s important is that it&#8217;s been built in as a configuration option that is enabled by default.  You don&#8217;t need to do anything to get this to work (and actually, if you&#8217;re using the JavaScript from the old version of the article, it may mess this up so be sure to remove it).<\/p>\n<p>However, if you want to make sure it&#8217;s working, or otherwise force it to be on, take a look at the following code:<\/p>\n<pre>&lt;?php\r\n\/\/ Start counting time for loading...\r\n$starttime = explode(' ', microtime());\r\n$starttime = $starttime[1] + $starttime[0];\r\n\r\ninclude('simplepie.inc');\r\n\r\n\/\/ Parse it\r\n$feed = new SimplePie();\r\nif (!empty($_GET['feed'])) {\r\n\t$feed-&gt;<a href=\"\/docs\/reference\/config\/feed_url\/\">feed_url<\/a>($_GET['feed']);\r\n\t<em>$feed-&gt;<a href=\"\/docs\/reference\/config\/bypass_image_hotlink\/\">bypass_image_hotlink<\/a>();<\/em>\r\n\t$feed-&gt;<a href=\"\/docs\/reference\/config\/init\/\">init<\/a>();\r\n}\r\n$feed-><a href=\"\/docs\/reference\/misc\/handle_content_type\/\">handle_content_type<\/a>();\r\n\r\n?&gt;&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\"&gt;\r\n\r\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" xml:lang=\"en-US\" lang=\"en-US\"&gt;\r\n&lt;head&gt;\r\n&lt;title>SimplePie: Demo<\/title&gt;\r\n<\/pre>\n<p>Have fun!  This code has been implemented in the demo that comes with the <a href=\"\/downloads\/\">SimplePie Beta 2 download<\/a>.\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Requirements: SimplePie 1.0 Beta 2 In my quest for making a feed parser that is intelligent, simple, and graceful, one thing that has always bugged me about online feed readers is that some people disable the ability to hotlink images. Now, I understand why they do this, because I do it too. You don&#8217;t want [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":0,"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"wp:attachment":[{"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simplepie.org\/blog\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}