Finestrat Posted September 30, 2013 Share Posted September 30, 2013 I'm a complete newbie to php and I'm trying to make a webcam .jpg image on my server into a hyperlink to a page on another of my sites. I've made a php file on the server where the image is located with the following code and called it imagem.php. The webcam picture is being uploaded to the root, public_html/webcam2.jpg This is the code I've used ?php<a href="http://www.apartmentsspain.co.uk/documents/la_cala_de_finestrat_webcam.php" img src='.webcam2.jpg'</a> ?> This doesn't work but when I open the file here http://www.holidaycottagegetaways.com/imagem.php I get the link but I can't seem to get the correct syntax for the image path. I've tried various things for the img src but I'm obviously going wrong somewhere. Can somebody point me in the right direction? This is the image url http://www.holidaycottagegetaways.com/webcam2.jpg The reason I want to do this is because a lot of sites have started using my webcam pic without linking back to my site so I've put a caption on the webcam pic with the url but it isn't a link. If I can get this working, I'll change the caption on the pic to click here for live view. Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/282559-creating-image-link/ Share on other sites More sharing options...
sasa Posted September 30, 2013 Share Posted September 30, 2013 it is HTML use <a href="http://www.apartment...webcam.php">< img src='.webcam2.jpg' ></a> remove php tag Quote Link to comment https://forums.phpfreaks.com/topic/282559-creating-image-link/#findComment-1451849 Share on other sites More sharing options...
Finestrat Posted September 30, 2013 Author Share Posted September 30, 2013 Thanks for the quick reply. Sorry, that doesn't put a link on my webcam picture. Not sure if I've explained this very well. I've got a webcam program which ftp's a jpg file every 30 seconds to my server. A lot of sites have copied the live source of the webcam jpg and are using it on their own websites without my permission and not linking back to me. I need to make the webcam jpg into a hyperlink so that the picture is linking back to my site so it becomes a link whichever site it is being used on. I think this is possible but I need a way of telling the server that the jpg is a hyperlink, I hope I've explained it a bit better. Quote Link to comment https://forums.phpfreaks.com/topic/282559-creating-image-link/#findComment-1451852 Share on other sites More sharing options...
Ch0cu3r Posted September 30, 2013 Share Posted September 30, 2013 (edited) You wont be able to turn the image into a link, as images requested with <img /> the browser is expecting an image to be returned not html. But what you can do is check if the request for the image is from your site, by checking the HTTP_REFERER header. If it doesn't match serve a different image which will say something like "See my webcam at http://yourdomain.com". This is called anti image hot linking. Search google for this term and there be some php examples of this. Edited September 30, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/282559-creating-image-link/#findComment-1451859 Share on other sites More sharing options...
Finestrat Posted September 30, 2013 Author Share Posted September 30, 2013 Hi Thanks for the reply. The image isn't in a webpage, it's in a seperate .jpg file on the server, would that make it possible? Quote Link to comment https://forums.phpfreaks.com/topic/282559-creating-image-link/#findComment-1451939 Share on other sites More sharing options...
Ch0cu3r Posted September 30, 2013 Share Posted September 30, 2013 In order for an image to display on a webpage you need to use the html image tag (<img src="path/to/image" />). If they are doing this then you cannot make the image a link. You can only display an image with the <img /> tag, not render html. When someone links to an image on another website without your consent this is called image hot linking. You will want to search google for anti image hotlinking techniques to stop them seeing the image and tell them to go to your website instead. Quote Link to comment https://forums.phpfreaks.com/topic/282559-creating-image-link/#findComment-1451943 Share on other sites More sharing options...
Finestrat Posted September 30, 2013 Author Share Posted September 30, 2013 Okay, I understand now, thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/282559-creating-image-link/#findComment-1451946 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.