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.

The script

Click here for the code

By Patrick Altoft. at 12:00AM on Thursday, 07 Jun 2007

Patrick is the Director of Strategy at Branded3 and has spent the last 11 years working on the SEO strategies of some of the UK's largest brands. Patrick’s SEO knowledge and experience is highly regarded by many, and he’s regularly invited to speak at the world’s biggest search conferences and events. Follow Patrick Altoft on Twitter.

comments

  • James Smith

    Wow. Neat idea. Thanks.

  • http://cmsmdy.com CMS

    Great tips :)

  • Brandon

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

  • http://blogstorm.co.uk Patrick Altoft

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

  • http://warintel.blogspot.com/ Gerald

    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

  • http://blogstorm.co.uk Patrick Altoft

    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

  • http://warintel.blogspot.com/ Gerald

    Thanks so much.

    g

  • http://personal-recovery-tools.com Gene

    Sound like a great idea, Thanks

  • http://ingovogelmann.com Ingo Vogelmann

    Waiting for the WP Plug! ;o)

  • http://forumjunkies.net Junkie

    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.

  • http://kpebiz.com KP

    Interesting and great idea… I will try it.

  • http://internetreklama.com/ dao

    great plugin , 10x

  • http://cutetube.blogspot.com syahid ali

    neat idea. thumbs up.

  • Martin Larsen

    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?

  • http://blogstorm.co.uk Patrick Altoft

    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

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

  • http://oscandy.com azzam

    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

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

  • http://blogstorm.co.uk Patrick Altoft

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

  • http://registercompass.com RegisterCompass

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

  • Martin Larsen

    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.

  • http://onedira.blogspot.com wandira

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

  • http://comradesmack.com Comrade Smack

    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

    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?

  • http://johninjapan.com HDR

    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?

  • http://johninjapan.com HDR

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

  • http://peoplecnc.com CNC support

    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

  • http://kamin-blog.de klaus

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

    greatings from germany
    klaus

  • http://posterior.com.au jimmy

    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.

  • http://givemelip.com comments for myspace

    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

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

  • http://buraak.com Bozdemir

    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

  • http://weakish.int.eu.org/blog/ weakish

    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.

  • http://areureadingthis.blogspot.com - r y u -

    wow… this is a great idea =)

  • http://ecommercewebsitehosting.org Ecommerce Solutions

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

  • http://soundbiteblog.com Kitsap County Real Estate

    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.

  • http://JFU.com JFU

    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.

  • http://foursquareinnovations.co.uk/ Chris

    What a cunning way to link build!

  • http://forwardslashmarketing.co.uk/ seo bristol

    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.

  • http://celebrityartist.blogspot.com/ faithxp

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

  • http://bigup.cz/ Edie

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

  • http://www.oaksenov.com Oleg

    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?

    • http://www.blogstorm.co.uk Patrick Altoft

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

  • http://www.cashjuke.com CashJuke

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

  • http://www.MyPE.co.za Alan

    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.

  • Pingback: Image Hotlinking and SEO : Are There Any Benefits?

  • http://www.no1wallpapers.com johnl

    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?

  • http://www.newmasalaboard.info Masalaboard

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

  • http://blog.codesignstudios.com Dennison Uy

    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.

  • http://www.sciencebase.com David Bradley

    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

  • http://www.eflight.com.au EFlight

    A brillant and original idea… !!

  • http://www.huskerspot.com Nebraska football

    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

  • http://www.qnkr.com Amir Mullick

    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.

  • http://www.fanoftheband.com Fan of the Band

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

  • http://www.mascali.net mascali

    Can you fix download link please?

  • http://liveimagephoto.com liveimagephotodotcom

    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.

  • http://ismartphones.net/sitemap/ Fan Of Smartphone

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

  • http://RadioTelephoneTutor.com Lassar

    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.  

  • http://www.jiglet.net John

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

  • Martin

    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.

  • http://lamanweb.biz Laman Web

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

  • http://www.cncmachine.110mb.com/ pravalika

    how to improve

  • Pingback: How to Optimize Images in Joomla - JoomlaK

  • http://www.dataoutsourcingindia.com Sujit

    Wonderful tips, thank you!!!

  • http://www.beritasemasa.com Berita Harian

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

  • http://www.dingjuled.com suzy

    vety great idea, it is wonderful!

  • http://www.bloommedia.co.uk stuartpturner

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

  • http://www.daretube.net Rednael

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

  • http://www.neotericuk.co.uk/ james

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

  • http://www.bestwallpapersite.com jakki

    Seems like a great idea.
    going to try it soon.
    Thanks for this useful option. :)

  • http://www.chaptereight.com jamie m

    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.

  • http://insurancebrokers-network.com Steve

    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

  • Pingback: 10 Powerful Tips to Leverage Content Theft | SEO Himanshu

  • http://www.squidoo.com/pet-treatment-for-domestic-carpets Otto Heaps

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

  • http://www.seowebmeeting.com Michael SEO Haley

    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!

  • http://www.getseenonline.com.au James Whitrow

    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!

  • http://www.dentistspreston.co.uk/ Preston Dental

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

  • http://suarapaulina.blogdetik.com/ Berita Terkini

    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.

  • Steve Rick

    I was just looking for something like this.

  • edybala

    Really like your section at the footer of your posts. I am new to coding. Do you have a post on how to create that? Thanks!