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

by Patrick Altoft on June 7, 2007

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 Leeds based digital & SEO agency Branded3. Patrick also runs Blogstorm.

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

Read some similar posts

{ 70 comments… read them below or add one }

James Smith 28 May 2007 at 8:11 am

Wow. Neat idea. Thanks.

CMS 07 Jun 2007 at 9:30 pm

Great tips :)

Brandon 08 Jun 2007 at 2:57 am

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

Patrick Altoft 08 Jun 2007 at 3:28 am

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

Gerald 08 Jun 2007 at 8:22 am

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

Patrick Altoft 08 Jun 2007 at 10:01 am

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

Gerald 08 Jun 2007 at 2:46 pm

Thanks so much.

g

Gene 09 Jun 2007 at 1:00 am

Sound like a great idea, Thanks

Ingo Vogelmann 11 Jun 2007 at 12:25 am

Waiting for the WP Plug! ;o)

Junkie 19 Jun 2007 at 7:27 am

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.

KP 19 Jun 2007 at 11:30 pm

Interesting and great idea… I will try it.

dao 20 Jun 2007 at 9:10 am

great plugin , 10x

syahid ali 21 Jun 2007 at 3:20 am

neat idea. thumbs up.

Martin Larsen 21 Jun 2007 at 9:59 am

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?

Patrick Altoft 21 Jun 2007 at 11:14 am

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.

Martin Larsen 22 Jun 2007 at 4:26 am

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

azzam 22 Jun 2007 at 6:25 am

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.

TRex2003 27 Jun 2007 at 1:55 pm

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

Patrick Altoft 27 Jun 2007 at 2:20 pm

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

RegisterCompass 27 Jun 2007 at 4:22 pm

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

Martin Larsen 02 Jul 2007 at 8:56 am

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.

wandira 03 Jul 2007 at 3:39 am

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

Comrade Smack 13 Jul 2007 at 12:29 am

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.

Denis 20 Jul 2007 at 6:59 pm

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?

HDR 23 Jul 2007 at 3:10 am

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 24 Jul 2007 at 9:30 am

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

CNC support 04 Aug 2007 at 1:13 pm

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

klaus 04 Aug 2007 at 11:07 pm

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

greatings from germany
klaus

jimmy 06 Aug 2007 at 11:38 am

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.

comments for myspace 15 Aug 2007 at 3:24 am

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!

colum kelly 17 Aug 2007 at 12:16 pm

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

Bozdemir 21 Aug 2007 at 6:39 am

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

weakish 31 Aug 2007 at 3:30 pm

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.

- r y u - 04 Sep 2007 at 7:31 am

wow… this is a great idea =)

Ecommerce Solutions 21 Sep 2007 at 9:18 am

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

Kitsap County Real Estate 04 Oct 2007 at 12:33 am

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.

JFU 25 Oct 2007 at 3:44 pm

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.

Chris 14 Nov 2007 at 6:19 pm

What a cunning way to link build!

seo bristol 21 Nov 2007 at 3:13 pm

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.

faithxp 10 Dec 2007 at 8:02 pm

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

Edie 13 Dec 2007 at 4:39 pm

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

Oleg 04 Jan 2008 at 1:59 pm

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?

Patrick Altoft 04 Jan 2008 at 8:27 pm
Find me on Twitter

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

More comments from Patrick Altoft
CashJuke 15 Feb 2008 at 10:14 pm

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

Alan 13 May 2008 at 7:04 am

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.

johnl 21 May 2008 at 5:06 pm

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?

Masalaboard 22 May 2008 at 2:07 pm

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

Dennison Uy 12 Jun 2008 at 3:28 pm

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.

David Bradley 13 Jun 2008 at 11:08 am

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

EFlight 18 Jun 2008 at 6:18 am

A brillant and original idea… !!

Nebraska football 18 Jun 2008 at 4:08 pm

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

Amir Mullick 10 Aug 2008 at 2:24 am

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.

Fan of the Band 11 Aug 2008 at 11:15 am

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

mascali 05 Oct 2008 at 6:32 am

Can you fix download link please?

liveimagephotodotcom 03 Nov 2008 at 8:53 pm

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.

Fan Of Smartphone 04 Nov 2008 at 8:40 pm

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

Lassar 16 Dec 2008 at 8:29 am

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.  

John 10 Apr 2009 at 3:53 pm

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

Martin 14 Apr 2009 at 3:37 pm

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.

Laman Web 23 May 2009 at 10:27 am

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

pravalika 01 Jun 2009 at 5:12 am

how to improve

Sujit 24 Jul 2009 at 4:15 pm
Find me on Twitter

Wonderful tips, thank you!!!

More comments from Sujit
Berita Harian 17 Oct 2009 at 8:02 am

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

suzy 19 Oct 2009 at 9:19 am

vety great idea, it is wonderful!

More comments from suzy
stuartpturner 07 Jan 2010 at 2:02 pm

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

Rednael 10 Mar 2010 at 11:25 am

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

james 19 Mar 2010 at 7:52 am

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

jakki 29 May 2010 at 8:30 am

Seems like a great idea.

going to try it soon.

Thanks for this useful option. :)

jamie m 17 Jun 2010 at 3:56 pm

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.

Steve 23 Jul 2010 at 3:43 pm

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

{ 2 trackbacks }

Image Hotlinking and SEO : Are There Any Benefits?
05.20.08 at 3:23 pm
How to Optimize Images in Joomla - JoomlaK
06.12.09 at 9:47 pm

Leave a Comment (registration is optional)

Registration is free, takes about 5 seconds and is worth doing.

You can use these HTML tags and attributes:
<a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>