How to use hotlinkers and Google Images to build natural links to your site

by Patrick Altoft on / 78 responses

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.

The script

Click here for the code

Patrick Altoft is Director of Search at Branded3, a Leeds SEO & Digital Agency specialising in SEO, Web Design, Development & Social Media.

Get daily posts direct to your inbox

You can get our blog posts delivered for free by email every day - simply add your email address to the box above, or alternatively you can grab the RSS feed.

Comments

Read the 75 comments below, or add your own!

James Smith
May 28, 2007 at 8:11am

Wow. Neat idea. Thanks.

Reply

CMS
June 7, 2007 at 9:30pm

Great tips :)

Reply

Brandon
June 8, 2007 at 2:57am

The script doesn’t work in your example… you can simply right click on the image and save it. Tested in Firefox 2.0

Reply

June 8, 2007 at 3:28am

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.:)

Reply

June 8, 2007 at 8:22am

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

Reply

June 8, 2007 at 10:01am

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. Smile

Reply

June 8, 2007 at 2:46pm

Thanks so much.

g

Reply

June 9, 2007 at 1:00am

Sound like a great idea, Thanks

Reply

June 11, 2007 at 12:25am

Waiting for the WP Plug! ;o)

Reply

June 19, 2007 at 7:27am

Trying to add it to the footer of http://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.

Reply

KP
June 19, 2007 at 11:30pm

Interesting and great idea… I will try it.

Reply

dao
June 20, 2007 at 9:10am

great plugin , 10x

Reply

June 21, 2007 at 3:20am

neat idea. thumbs up.

Reply

Martin Larsen
June 21, 2007 at 9:59am

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?

Reply

June 21, 2007 at 11:14am

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.

Reply

Martin Larsen
June 22, 2007 at 4:26am

I was actually thinking about Joomla. How far is he?

Reply

June 22, 2007 at 6:25am

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.

Reply

TRex2003
June 27, 2007 at 1:55pm

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).

Reply

June 27, 2007 at 2:20pm

It works in FF and IE 90% of the time.

Reply

June 27, 2007 at 4:22pm

Thanks for information … does anyone has an example url to check the backlinks given from this script?

Reply

Martin Larsen
July 2, 2007 at 8:56am

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.

Reply

July 3, 2007 at 3:39am

Are there any way for this to work on Blogger account ?

Reply

July 13, 2007 at 12:29am

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.

Reply

Denis
July 20, 2007 at 6:59pm

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?

Reply

HDR
July 23, 2007 at 3:10am

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?

Reply

HDR
July 24, 2007 at 9:30am

Hmm I can’t get this working. Do I add the php to my main template then the script to a content item?

Reply

August 4, 2007 at 1:13pm

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

Reply

August 4, 2007 at 11:07pm

A great idea, but I should prefer to wait for the WordPress Plugin.

greatings from germany
klaus

Reply

August 6, 2007 at 11:38am

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.

Reply

August 15, 2007 at 3:24am

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!

Reply

colum kelly
August 17, 2007 at 12:16pm

You do realise that anyone who knows html will be able to just delete the link to your site. Good idea though.

Reply

August 21, 2007 at 6:39am

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 Smile

Reply

August 31, 2007 at 3:30pm

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.

Reply

September 4, 2007 at 7:31am

wow… this is a great idea =)

Reply

September 21, 2007 at 9:18am

Nice idea, if they hotlink (and use your bandwith), you obtain an IBL in return. Seem fair.

Reply

October 4, 2007 at 12:33am

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.

Reply

JFU
October 25, 2007 at 3:44pm

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.

Reply

November 14, 2007 at 6:19pm

What a cunning way to link build!

Reply

November 21, 2007 at 3:13pm

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.

Reply

December 10, 2007 at 8:02pm

IS it applicable now to a blog site., I have a blog and I want to put that script on it., Is it possible.,?

Reply

December 13, 2007 at 4:39pm

Hello, how is it looking with wordpress plugin? Thank you for reply.

Reply

January 4, 2008 at 1:59pm

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?

Reply

January 4, 2008 at 8:27pm

The script was disabled when I moved to WordPress yesterday, sorry. The plugin still works though if you install it on your blog.

Reply

February 15, 2008 at 10:14pm

That’s seriously neat.
You got yourself a new reader :D

Reply

May 13, 2008 at 7:04am

Great Idea.

I have another take on the hotlinking issue – the harder you make it for people to ‘steal’ your bandwidth the less chance you have of someone returning to your site. It is almost as if you are saying to your visitor; “We don’t trust you, now go away!”

We employ two different methods of encouraging people to link back when ‘borrowing’ images:

1. In our images gallery our No Right click javascript has a simple message that says: “If ‘BORROWING’ images please credit: http://www.MyPE.co.za – Port Elizabeth Community Web Site” – slightly humorous and one more way to get our name and URL in front of our visitors.
2. The images that are hotlinked eventually show up in our stats program as popular and then we go back to the image and add our URL – at least this way we get some advertising every time the image is shown.

Reply

May 21, 2008 at 5:06pm

I have thousands of wallpapers on my site so it would be fantastic if this works

I notice that a lot of people are having trouble with it though so can someone pos tif and when it works

Also what is “I would use a layer above the image (the blank-trick).” mentioned in a comment above?

Reply

May 22, 2008 at 2:07pm

You do realise that anyone who knows html will be able to just delete the link to your site. Good idea though.

Reply

June 12, 2008 at 3:28pm

I will definitely give this a shot. It would have been nice though if the JavaScript only prevented right-clicks on the image itself. Disabling right-clicks on the entire page may annoy users who try to copy text.

Reply

June 13, 2008 at 11:08am

I see what happens when I right-click the image in the demo page, is that what would be displayed if someone were to hotlink your image? I did an images search for blogstorm, clicked a graphic, that opened a post as normal.

I have a script running that is presumably similar that shows the image along with a notice about hotlinking when someone clicks through from an image search.

db

Reply

June 18, 2008 at 6:18am

A brillant and original idea… !!

Reply

June 18, 2008 at 4:08pm

Is there a way to use this for images on Ning social networks? I will gladly link to this site and do whatever – it would just be awesome if I can get this to work for a branded Ning.com social network I’ve created!!

Any help is appreciated!
Nate

Reply

August 10, 2008 at 2:24am

I have the sites below:

http://www.yqvm.com http://www.yqrg.com http://www.rijq.com

They are proxies with the logo that is a unique image, and people are always using it for something, which is so awkward…thanks for this, I will tell my friends about it too, and it should help, so i will buy it soon too.

Reply

August 11, 2008 at 11:15am

Where is the script? I get a 404 page :(
Please fix it.
Thanks !

Reply

October 5, 2008 at 6:32am

Can you fix download link please?

Reply

November 3, 2008 at 8:53pm

is there anyway you can update your wordpress plugin, the box pops up if you right-click anywhere (link or image) on a page. Can you make exceptions to work on .jpg .gif .png only? thanks and great plugin.

Reply

November 4, 2008 at 8:40pm

Patrick, please fix the download link. When I try to download the script I got error 404 page.

Reply

December 16, 2008 at 8:29am

I have been doing some reading on image search engines. According to what I have read that the thing to do is to stop frames.

This is the javascript from Don’t Lose Your Google Image Search Traffic

if (top.location != self.location) top.location.replace(self.location);

More scripts to bust frames.  

Reply

April 10, 2009 at 3:53pm

Very cool idea. The link to the script is broken though, can you fix that? I’d like to try and implement this.

Reply

Martin
April 14, 2009 at 3:37pm

I think it is just too easy to copy the image like that, I can actually use Snagit to copy the image. I think it is good just to place the watermark on the image.

Reply

May 23, 2009 at 10:27am

Actually there is a simple way to overcome this? Just highlight the image and press Ctrl + C. Am I right?

Reply

June 1, 2009 at 5:12am

how to improve

Reply

July 24, 2009 at 4:15pm

Wonderful tips, thank you!!!

Reply

October 17, 2009 at 8:02am

Nice idea, great tips..Thanks for sharing! :)

Reply

October 19, 2009 at 9:19am

vety great idea, it is wonderful!

Reply

January 7, 2010 at 2:02pm

Bit of a late question but – are there any conflicts running this script and using a digital watermark as well?

Reply

March 10, 2010 at 11:25am

I used this technique on http://www.daretube.net!
Great tips!

Reply

March 19, 2010 at 7:52am

I wana do the same thing but by htaccess file. Do you have an idea how can it possible.

Reply

May 29, 2010 at 8:30am

Seems like a great idea.

going to try it soon.

Thanks for this useful option. :)

Reply

June 17, 2010 at 3:56pm

Wow this is actually useful, thanks for this, will it work if i add tracking code onto the links? I would like to see just out of interest the stats n clicking etc.

Reply

July 23, 2010 at 3:43pm

Gee, I wondered why my "Save Image As" function wasn't working, the last time I tried to appropriate a few measly images that probably never would have been seen on my miserable excuse for a web site.

Thanks for the post and the recent update. Does the plug slow load time?

Steve Benedict

Reply

November 10, 2010 at 11:59pm

Usefull post do you mind if i translate into Spanish for my blogs viewers? Thanks

Reply

December 1, 2010 at 12:25am

I have been in the SEO business for years and rarely pick up new tricks… but this is one of those magical moments. Thanks, you guys are cutting edge!

Reply

April 20, 2011 at 1:08am

Thanks very much for this! Not sure how I didn’t come across this before, will be very useful for many of my clients. Keep up the awesome work!

Reply

October 19, 2011 at 11:07pm

Great tips, dead easy but extremely useful, Genius !!! thanks

Reply

January 15, 2012 at 12:17pm

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.

Reply

3 trackbacks

Leave a comment

Your email address will not be published. Fields marked with an asterisk are required.
 

  *

  *

You can use one of the following tags:
<a href=""><blockquote><code><em><strike><strong>