gdfhghjdfghgfhf Posted September 24, 2012 Share Posted September 24, 2012 I'm looking for a way to hide the URL of the remote images included in one of my page. I've done that : $image = base64_encode("https://www.google.ca/images/srpr/logo3w.png");echo "<img src=\"image.php?img=$image\">"; $path = base64_decode(addslashes($_GET['img']));$image = imagecreatefromstring(file_get_contents($path)); header('Content-type: image/png'); imagepng($image); exit(); But it makes the loading of the page really slower because the image needs to be loaded on my server before being displayed to the users... So i'm looking for a faster way to do it... Any idea ? Maybe with htaccess ? Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/ Share on other sites More sharing options...
requinix Posted September 24, 2012 Share Posted September 24, 2012 (edited) You cannot hide the URL of an image from the user. It is impossible. What you can do is give the URL to an "image" on your server which then outputs the appropriate image. Note I said output, not redirect. That's the same thing you're doing now. And you should know that base-64 encoding is really, really easy to identify. What you're doing is trivial to unravel. Edited September 24, 2012 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380513 Share on other sites More sharing options...
Christian F. Posted September 24, 2012 Share Posted September 24, 2012 Why would you want to hide the picture's URLs from the user? They can just right click on them, select "properties" and see where they come from anyway. If it's to prevent people from downloading them, then you should know that the browser has already downloaded all of the files it shows; Otherwise it cannot show them to the user. Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380518 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted September 24, 2012 Author Share Posted September 24, 2012 (edited) What you can do is give the URL to an "image" on your server which then outputs the appropriate image. Note I said output, not redirect. That's the same thing you're doing now. That's what i meant by "hiding" the real URL. But the way i am doing it, the server must load the content of the image before displaying it to the user and it makes the page loading time longer... Is there a better way ? Why would you want to hide the picture's URLs from the user? They can just right click on them, select "properties" and see where they come from anyway. If it's to prevent people from downloading them, then you should know that the browser has already downloaded all of the files it shows; Otherwise it cannot show them to the user. I don't care if the users download the image. I just don't want them to know where it's coming from. I want them to think the image is hosted on my server, not on a remote website. Edited September 24, 2012 by ungovernable Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380524 Share on other sites More sharing options...
Christian F. Posted September 24, 2012 Share Posted September 24, 2012 You got permission from the remote website to do this then? Also, if you want to cut down on the latency time, the only thing you can do is to actually host the images on your own server. Otherwise the users have to wait for your server to download them, before it can send the data onwards to their browsers. Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380531 Share on other sites More sharing options...
requinix Posted September 24, 2012 Share Posted September 24, 2012 That's what i meant by "hiding" the real URL. But the way i am doing it, the server must load the content of the image before displaying it to the user and it makes the page loading time longer... Is there a better way ? Nope. The image has to come from, or through, your server. You know Google has an image search, right? I can give the URL of an image and it'll find the places where it's used. So even hiding the URL perfectly like you're doing now can be defeated. Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380645 Share on other sites More sharing options...
krakjoe Posted September 24, 2012 Share Posted September 24, 2012 Just outputting expiration headers will improve the situation ... other than that you might want to think about locally caching the images rather than fetching the real location ( which I assume is cross network ) everytime ... Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380648 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted September 24, 2012 Author Share Posted September 24, 2012 You got permission from the remote website to do this then? Yes. This is my website. Here's my situation: I have a spreadshirt t-shirt shop hosted on Spreadshirt.com. I'm building a php website to display my shop on my own website using their API, so the users will think it's my own shop. But the images are still hosted on Spreadshirt.com If the users know the shop comes from Spreadshirt, they can just copy my images and make their own t-shirts from my supplier. I think i may just consider taking the binaries from the images and storing it in my database as Blob Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380686 Share on other sites More sharing options...
kicken Posted September 24, 2012 Share Posted September 24, 2012 If the users know the shop comes from Spreadshirt, they can just copy my images and make their own t-shirts from my supplier. Hiding the URL isn't going to stop anyone from taking the images if they want to take them. Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380691 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted September 24, 2012 Author Share Posted September 24, 2012 Hiding the URL isn't going to stop anyone from taking the images if they want to take them. Yes but they won't be linked to my t-shirt supplier. I just want to hide where the tshirts are printed. Quote Link to comment https://forums.phpfreaks.com/topic/268733-hide-remote-image-url/#findComment-1380700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.