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

  • 1
  • June 7, 2007
Patrick Altoft

Patrick Altoft

Director of Strategy

Are you tired of people using images from your website without linking back to you? This simple script has the answer.

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.


$match = Array();

if (preg_match(“/<img[^>]*>/”, $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.