{"id":472,"date":"2011-02-22T23:47:38","date_gmt":"2011-02-22T23:47:38","guid":{"rendered":"http:\/\/abcnotation.com\/blog\/?p=472"},"modified":"2015-05-09T13:23:52","modified_gmt":"2015-05-09T12:23:52","slug":"stop-thief","status":"publish","type":"post","link":"https:\/\/abcnotation.com\/blog\/2011\/02\/22\/stop-thief\/","title":{"rendered":"Stop thief"},"content":{"rendered":"<p>I&#8217;ve recently been playing around with some code to prevent\u00a0<a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Hotlinking');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Hotlinking\">hotlinking<\/a> of the images on the site.<\/p>\n<p>Hotlinking is when a page in one website displays an image served from another website.<\/p>\n<p><!--more-->It&#8217;s usually frowned upon as it uses the bandwidth of the server at the image&#8217;s website without giving credit to that website. In fact it&#8217;s sometimes called <em>bandwidth theft<\/em>, especially by webmasters who pay for bandwidth by the gigabyte &#8211; apart from the copyright issues, every time someone looks at an image stolen from your website, you have to pay to provide it. It&#8217;s like having someone steal your car and then getting you to pay for the petrol &#8230; forever!<\/p>\n<p>It&#8217;s usually frowned on, that is, unless it&#8217;s Google doing it (or any one of a number of image search engines) in which case it&#8217;s <em>a good thing<\/em>, as Google does give credit to the host website and, more importantly, sends traffic to it.<\/p>\n<p>Fortunately, it&#8217;s not too difficult to detect where an image is being displayed and, for any requests that come from unrecognised websites,\u00a0substitute another picture. You can even give the bandwidth thieves a\u00a0<a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.swollenpickles.com\/2007\/09\/07\/how-i-stopped-a-bandwidth-thief\/');\"  href=\"http:\/\/www.swollenpickles.com\/2007\/09\/07\/how-i-stopped-a-bandwidth-thief\/\">nasty surprise<\/a> or <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.bbc.co.uk\/news\/technology-12450348');\"  href=\"http:\/\/www.bbc.co.uk\/news\/technology-12450348\">warn off their potential customers<\/a>.<\/p>\n<p>I tried this approach for about a week recently, serving up the following, fairly innocuous image, instead of the one that had been requested:<img decoding=\"async\" loading=\"lazy\" class=\"aligncenter\" title=\"hotlink substitution\" src=\"\/res\/img\/unused\/hotlink.png\" alt=\"hotlink substitution\" width=\"200\" height=\"100\" \/>However, it isn&#8217;t always easy to tell which requests are benign (Google, Yahoo, etc) and which are not. For example, how about images sent in emails (which I can&#8217;t read).<\/p>\n<p>So in the end I decided it was easier just to serve up the image as requested, but make sure it had &#8220;www.abcnotation.com\/tunes&#8221; at the bottom as an indication of its source.<\/p>\n<p>So now you know.<\/p>\n<p>Chris<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently been playing around with some code to prevent\u00a0hotlinking of the images on the site. Hotlinking is when a page in one website displays an image served from another website.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[395,172,413,414,349],"_links":{"self":[{"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/posts\/472"}],"collection":[{"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/comments?post=472"}],"version-history":[{"count":7,"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/posts\/472\/revisions"}],"predecessor-version":[{"id":738,"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/posts\/472\/revisions\/738"}],"wp:attachment":[{"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/media?parent=472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/categories?post=472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abcnotation.com\/blog\/wp-json\/wp\/v2\/tags?post=472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}