I am trying to obtain and display a remote image from a url in PHP. Most images work, however some images redirect for example:
http://thundafunda.com/33/World-tour/download/Grand%20Canal,%20Venice,%20Italy%20pictures.jpg
The image would load and then disappear. I am using an IMG tag and placing that url as the source. Any idea?
Using this portion of code, that doesn’t do anything except display an
<img>tag :I get the same kind of behavior you are describing : the image is not displayed.
If I take a look at what’s happening on the network level, using Firebug, I see this :
(source: pascal-martin.fr)
Basically :
302HTTP status codeLocationheader of the response — which points to an HTML pageWhich, of course, cannot be displayed in an
<img>tag.If you do exactly the same test, disabling the
Referer(some Firefox extensions can do that), you’ll see the image is displayed properly — and Firebug says :(source: pascal-martin.fr)
Note that there is no Referer header, this time, in the Request sent from my Browser.
Considering this, I would bet there is some kind of anti-hot-linking protection that’s been setup by the website hosting that image…
And there is not much you can do, except host the file on your own server — if the licence allows you to.