How to use hotlinkers and Google Images to build natural links to your site
Are you tired of people using images from your website without linking back to you? This simple script has the answer.
View the demo here (right click on the image). Note that I prefer to only run this script for users who arrive from an image search engine rather than for everybody.
Most website owners hate hotlinkers and blame them for stealing valuable bandwidth and costing the website owner money without giving anything in return. In fact, images can be a very valuable way to build links to your site.
First of all, a few points to note. If you want to stop people hotlinking your images this script isn’t for you, turning off hotlinking is an easy option in cPanel and fairly straightforward in htaccess as well. Also this strategy isn’t really recommended unless you have unlimited bandwidth hosting. Some sites using this script use over 100GB a week just from hotlinked images.
The good stuff
Remember that the majority of internet users who are looking for images to use on an eBay auction, blog post, myspace profile etc aren’t aware of the implications hotlinking can have and are even less aware of the benefits that the backlink will provide to your website.
Most of you are probably thinking that your regular users will be upset if they can’t use the right click function and you are quite correct.
The best way to make use of the script is to only show it to visitors who arrive from Google Images, Yahoo Images or MSN Live Search Images. Most of these visitors are likely to be after your images rather potential new customers so its safe to use this script. The key is to set a cookie when they arrive that expires after an hour, if the visitor likes your site and stays around you don’t want to upset them.
Of course if your site doesn’t have any regular users but enjoys traffic from Google Images then it might be acceptable to use this script all the time, in that case simply remove the cookie dependence.
What if I have thousands of pages?
This script works perfectly on database driven sites with lots of pages as long as your images are referenced in the database somehow. For example a product site will have an image of a product on each page and you will be able to use the image location to populate the textbox that hotlinkers will see.
If you are running a blog with lots of images embedded in the posts the script is a little harder to install. My favourite method is to parse the entire post and use a preg_match to find and output the images.
<?php
$match = Array();
if (preg_match(”/]*>/”, $blogpost, $match) !== FALSE) {
// Make sure it truely was a match
if ((count($match) != 0) && ($match[0] != “”)) {
// Save the image
$theImage = $match[0]; //image now saved as $theImage
}
}
?>
Note: make sure you add a safeguard to handle posts with no images.















Wow. Neat idea. Thanks.
James Smith May 28, 2007 8:11 am | Reply
Great tips
CMS June 7, 2007 9:30 pm | Reply
The script doesn’t work in your example… you can simply right click on the image and save it. Tested in Firefox 2.0
Brandon June 8, 2007 2:57 am | Reply
Hi Brandon.
The script should work on most browsers, including Firefox, unless you have Javascript support turned off.
It’s not really intended to stop people taking your images, the intention is to try and get a few links from the people who do.
Even if it only works for 50% of the users it gets you 50% more links than without using it.:)
Patrick Altoft June 8, 2007 3:28 am | Reply
ok there are 3 parts to add this to my blogger?
(just one page?)
#1) Where do I add the “preg_match”
#2) add a safeguard to handle posts with no images.( where do I get this safe guard?)
#3) the script goes in the body?
Thanks
Gerald
Gerald June 8, 2007 8:22 am | Reply
Gerald I don’t think you will be able to run the php parts of this script using Blogger.

However I will produce and test a version that is compatible with Blogger and other sites that can’t use php and post it to the blog later today.
Patrick Altoft June 8, 2007 10:01 am | Reply
Thanks so much.
g
Gerald June 8, 2007 2:46 pm | Reply
Sound like a great idea, Thanks
Gene June 9, 2007 1:00 am | Reply
Waiting for the WP Plug! ;o)
Ingo Vogelmann June 11, 2007 12:25 am | Reply
Trying to add it to the footer of www.forumjunkies.net and get the following errors -
The following error occurred when attempting to evaluate this template:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/forumjun/public_html/includes/adminfunctions_template.php(3596) : eval()\’d code on line 44
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
Junkie June 19, 2007 7:27 am | Reply
Interesting and great idea… I will try it.
KP June 19, 2007 11:30 pm | Reply
great plugin , 10x
dao June 20, 2007 9:10 am | Reply
neat idea. thumbs up.
syahid ali June 21, 2007 3:20 am | Reply
I am not quite sure I understand how to use the script. Does just including it one each page make it work? By looking at the code, it looks to me as if you need a little more code to wrap each image on the page into the imagelayer stuff. Like a regex to grab all the images, and then embed them in the layers in a foreach.
Is that correct?
Another question. How is this script licensed? May I make a plugin for a CMS using it?
Martin Larsen June 21, 2007 9:59 am | Reply
You would need to use a regex to grab the images and put them in the code. I have released a Wordpress plugin and there is another developer working on a Joomla plugin.
We are happy for you to create a plugin as long as you tell people where you got the idea and link back to this site.
Patrick Altoft June 21, 2007 11:14 am | Reply
I was actually thinking about Joomla. How far is he?
Martin Larsen June 22, 2007 4:26 am | Reply
martin, i was planning on the Joomla version however have not yet got round to it to be honest got a bit tied down with other work and the issue with Joomla GPL licensing that has got us developers in a stir.
If you are willing to do it then by all means go ahead. If not I will try to make some time for it.
azzam June 22, 2007 6:25 am | Reply
This does not work in Opera (I didnt expect it to work, Opera blocks all the right-click Scripts). If it really doesnt work in FF, then there is almost no sense in using it at all. I would use a layer above the image (the blank-trick).
TRex2003 June 27, 2007 1:55 pm | Reply
It works in FF and IE 90% of the time.
Patrick Altoft June 27, 2007 2:20 pm | Reply
Thanks for information … does anyone has an example url to check the backlinks given from this script?
RegisterCompass June 27, 2007 4:22 pm | Reply
I am a commercial Joomla developer myself, and the licensing issue is truly annoying!
I need it for a private site so the licence issue does not matter here, though.
Martin Larsen July 2, 2007 8:56 am | Reply
Are there any way for this to work on Blogger account ?
wandira July 3, 2007 3:39 am | Reply
This doesn’t really work. Repressing the ability to right click doesn’t really stop anyone. You can still get to the images by File > Save as..-ing.
The only real way to stop people from hotlinking is rather supressing it entirely or exchange it with a replaced image.
Comrade Smack July 13, 2007 12:29 am | Reply
Hello Patrick,
Thank you for the idea. I’ve just implemented your script on our website, but it works not exatly the way it is supposed to work.
When I right-click somewhere on the page (for example, I want to copy some text) the box with the code appears, but user expects to see context-menu and click “Copy”.
Could you please tell if it is possible to make the code appear only when user right-clicks on the image, but not anywhere on the page?
Denis July 20, 2007 6:59 pm | Reply
My Joomla website is very image heavy, I would kill for a Joomla mambot that would automate this script. Can you add me to some type of mailing list in case you ever release a Joomla version please?
HDR July 23, 2007 3:10 am | Reply
Hmm I can’t get this working. Do I add the php to my main template then the script to a content item?
HDR July 24, 2007 9:30 am | Reply
I’m testing the script, however getting an error: Parse error: parse error, unexpected \’{\’ in …
line is
if (isset($_COOKIE[\”imagesearcher\”]) {
Not sure what the error is, { it is opening, but do not know where it close ??? Any idea
CNC support August 4, 2007 1:13 pm | Reply
A great idea, but I should prefer to wait for the Wordpress Plugin.
greatings from germany
klaus
klaus August 4, 2007 11:07 pm | Reply
It would be good if you could make it so that the code box is displayed without having to right click. So it is permanently there. Is there a way to do that?
As right clicking on any where on the page will bring up the code box.
jimmy August 6, 2007 11:38 am | Reply
Do you have a page/forum/area with a more detailed description on how to install/add this for noobs? I really like the idea and it looks like it works awesome here in the sample but I am completely lost on how to add it to a non blog site. I would like to add it to a site like this myspace comment site http://givemelip.com but the code given above as the script confuses me a bit (total noob unfortunately lol). It looks like the code includes the code for the dog image above so does that mean we have to add this code to every page that has images and change the bottom part where the dog code is for each and every image? Are there other steps than just adding the code to the page? Maybe a step-by-step for a total dumbass noob somewhere lol?
Regardless, it’s an awesome script and I hope I can figure out how to use it. Thanks for providing it!
comments for myspace August 15, 2007 3:24 am | Reply
You do realise that anyone who knows html will be able to just delete the link to your site. Good idea though.
colum kelly August 17, 2007 12:16 pm | Reply
Again this may not work for some users, they may just copy the image source “http://www.blogstorm.co.uk/images/firefox-puppy.jpg”
not the whole code
Bozdemir August 21, 2007 6:39 am | Reply
In iceweasel 2.0.0.6, this script works without disabling right click. I think this is the best result for both site owner and visitors.
weakish August 31, 2007 3:30 pm | Reply
wow… this is a great idea =)
- r y u - September 4, 2007 7:31 am | Reply
Nice idea, if they hotlink (and use your bandwith), you obtain an IBL in return. Seem fair.
Ecommerce Solutions September 21, 2007 9:18 am | Reply
I’ve been chuckling for the last 5 minutes. What a great way to turn an irritation into a bonus! Talk about out-of-the-box thinking. Last month we had 3791 inbound links from Google Images, this month (on the 3rd) we’ve already had 652. This was beginning to become a problem. I’ve been manually re-branding my images with an ugly warning whenever I found someone hotlinking. I like this idea much better.
PS- You can thank Text Link Ads for sending me to this article.
Kitsap County Real Estate October 4, 2007 12:33 am | Reply
I can see a benefit from tying to gain backlinks.
But if someone is capable of creating an image on their site hotlinked to yours, then they should be able to view the page source and find the image src for ‘firefox-puppy.jpg’.
On top of which, the print screen button works wonders for capturing stubbon images from web pages.
JFU October 25, 2007 3:44 pm | Reply
What a cunning way to link build!
Chris November 14, 2007 6:19 pm | Reply
Having just said how much I like this solution on SEJ I thought it only polite to thank you in person!
Thank you for a great - out of the box - method of gaining links.
seo bristol November 21, 2007 3:13 pm | Reply
IS it applicable now to a blog site., I have a blog and I want to put that script on it., Is it possible.,?
faithxp December 10, 2007 8:02 pm | Reply
Hello, how is it looking with wordpress plugin? Thank you for reply.
Edie December 13, 2007 4:39 pm | Reply
Patric, is script supposed to prevent me from copying the above image from this post? If so it does not do it for me. I have tried from both IE and Firefox and was able to get the image in both. Am I missing anything?
Oleg January 4, 2008 1:59 pm | Reply
The script was disabled when I moved to Wordpress yesterday, sorry. The plugin still works though if you install it on your blog.
Patrick Altoft January 4, 2008 8:27 pm |
ReplyThat’s seriously neat.
You got yourself a new reader
CashJuke February 15, 2008 10:14 pm | Reply