views:

57

answers:

1

My site is requesting a remote image which is being transferred with the wrong MIME type. I was wondering how might I override it in PHP to tell it that it's an image? I can't use header('Content-Type') because the image is being used in a HTML document.

http://manga.justcarl.co.uk/N/Naruto/494/1 - one of the pages attempting to request an image... the image looks broken because it's trying to output it as html

A: 

I think you need to look at possibly the server configuration (or maybe a .htaccess file?) in this case. You won't be able to make a solution for this in PHP unless you can change the img src attribute.

Check this direct link to the image, it says 403 forbidden for me. Is it different for you?

Nate Pinchot
Really? Forbidden? No, they've all been loading fine with direct links... I get a forbidden header if I request the image in my page though... one of the reasons I'm so confused :/I came across .htaccess ForceType, but it isn't working so I'm assuming it's just for local files. How do you mean change the img src attribute? It has a .jpg tag on the end if that's what you mean? :P
Mr Carl
Sorry I should have been more clear. When I said change the img src attribute, I meant you would have to point the img src to a .php script that loads the image if you wanted to make a solution for this issue in PHP (and while that is entirely doable and could be a good workaround, it is probably not a good long term solution). Sorry I am not familiar with nginx, but I would check out the nginx configuration and see if there is a referrer check for images or something similar that would cause a 403.
Nate Pinchot
Ahhh, god I came across php images, that should have clicked :P good advice, will look into it, cheers :)
Mr Carl
Your suggestion for php image worked ^^ though it's more work for the server and no browser caching, but definitely a good temporary solution :) hehe
Mr Carl