Quantcast

Preventing People From Leeching Your Images!

Get the WebProNews Newsletter:


[ Business]

This tutorial will demonstrate how you can prevent other people from displaying YOUR images on their websites.

By this I mean people actually loading images on their site, from your website. This is a big problem as it will increase the bandwidth used on your account and therefore increasing your expenses. Many of you have seen the same thing in you use AngelFire free hosting. If you have an account with them and you want to display your image:

<img src="http://www.angelfile.com/memberaccount/images/image.gif" border="0">

Now, unless the image is being called from within the AngelFire system, you get an ugly image saying “We’re sorry, this image is hosted by AngelFire“. Creating a system that does this is fairly easy in ColdFusion. Let me show you how it’s done.

Now before I get to the explanation, some of you might be saying, wait a minute.. what do you mean? I’ve never used AngelFire

So, I’ll explain by showing, in the past when you wanted to display your images you used the standard:

<img src="/images/logo.jpg" border="0" alt="My Logo">

The problem with this is that people would view your source or right click on the image and see the direct path to your image. This could be a problem, specially if you don’t want your image to be displayed on other places by having it be loaded from your server. Anyone out there could simply use:

<img src="http://www.yoursite.com/images/logo.jpg" border="0" alt="My Logo">

This could cost you lots of money, specially if it’s a very popular image :)

Your alternative? This tutorial…

You can now load your images as follows:

<img src="/load_image.cfm?Image=logo.jpg" border="0" alt="My Logo">

Pretty nifty, huh? ok, let me explain what you must do to achieve this… the first thing we need to do is to create a file called: load_image.cfm

<!--- File load_image.cfm --->
<!--- First define the PHYSICAL path to the images --->
<cfset images_path = "C:inetpubwwwrootmysite.comimages">

The image path above will be where all the images are stored, the beauty of this script is that the images can even be in a folder that is NOT internet accessible.

<!— The next thing we do is verify that the image is being loaded from our site, and not someone else’s —>
<cfif NOT CGI.REFERER contains “mysite.com”>
&nbsp&bnsp&nbsp &nbsp <!— Someone is trying to load this image from another place, stop them! —>
&nbsp&nbsp&nbsp&nbsp <!— The first thing we MUST do is load the smaller/error message file —>
&nbsp&nbsp&nbsp&nbsp <cfcontent type=”image/gif” file=”#images_path#noleech.gif”>
<cfelse>
&nbsp&nbsp&nbsp <!— image is good, server the content —>
&nbsp&nbsp&nbsp <cfif Right(Image, 3) eq “gif”>
&nbsp&nbsp&nbsp <cfcontent type=”image/gif” file=”#images_path##Image#”>
&nbsp&nbsp&nbsp <cfelseif Right(Image, 3) eq “jpg”>
&nbsp&nbsp&nbsp <cfcontent type=”image/jpg” file=”#images_path##Image#”>
&nbsp&nbsp&nbsp </cfif>
</cfif>

OK, what the code above is doing is basically this:

  • First, check to make sure that the image being called is coming from YOUR site and not someone else’s.

    &nbsp&nbsp – If the call IS coming from your site, then it loads the image required and servers it to the calling web page.

    &nbsp&nbsp – If the call IS NOT coming from your site, it will load a different (SMALLER) image, therefore saving you bandwidth and not allowing that individual to load the image from their site.

  • The next thing is does is basically output the image. So that the page calling it will display it correctly.
  • Now on the pages you want the images to display you basically do this:

    <div align="center">
    &nbsp <img src="http://www.mysite.com/load_image.cfm?Image=logo.jpg" border="0" alt="My Company Logo">
    &nbsp <BR>
    &nbsp Our company logo!
    </div>

    this will ONLY work if it is being loaded from your web site, so if people view the source on the page, they will see this and not the actual path to the image itself.

    NOTE: If you don’t have an image to display when people are trying to steal your content, try this one:

    To save right-click on it and save to your computer.

    Need Another possible use for this tutorial?

    Maybe if some of you want to know how many times an image was loaded. You could use this script to implement a counter system for your images. Remember that you have a .CFM page loading the image, so you could do anything you wanted right before serving the image. :-)

    Well, That’s pretty much it… Remember, this script will NOT stop people from downloading the images to their hard drives (That’s pretty much impossible) but by hiding the paths to your images, people cannot load your images on their sites, using your bandwidth.

    EasyCFM.Com introduces at least three new tutorials each week, written by the webmaster (Pablo Varando) and also from individual people who post their own tutorials for visitors to learn from. For more information please visit: http://www.easycfm.com [EasyCFM is Hosted by Colony One On-Line - http://www.colony1.net]

    Preventing People From Leeching Your Images!
    Comments Off
    About Pablo Varando
    EasyCFM.Com introduces at least three new tutorials each week, written by the webmaster (Pablo Varando) and also from individual people who post their own tutorials for visitors to learn from. For more information please visit: http://www.easycfm.com [EasyCFM is Hosted by Colony One On-Line - http://www.colony1.net] WebProNews Writer
    Top Rated White Papers and Resources

    Comments are closed.

    • Join for Access to Our Exclusive Web Tools
    • Sidebar Top
    • Sidebar Middle
    • Sign Up For The Free Newsletter
    • Sidebar Bottom