Brewsterware

March 15, 2009

WordPress hotlink prevention plugin

Filed under: Internet,Software,Wordpress — Joe Brewer @ 1:56 pm

One of the things that I got from Think Visibility was Patrick Altoft‘s idea of getting links back to a blog by using a bit of javascript that presents links to a user when they right click on an image – right click on the image below for a demonstration.

Reliant Robin on fire

Reliant Robin on fire

I’d seen this before and used the code, but really wanted a way to add the functionality to my sites that was easier to implement (I’m quite lazy). Michael VanDeMar later improved Patrick’s code with a funky (and pretty amazing) implementation – you can download the javascript only version here.

After Think Visibility I sat down a wrote a wordpress plugin that includes the javascript and automatically adds the javascript code to each image. I’ve modified Michael’s code slightly so that I can pass a link to the window that pops up – this is so that any images from posts that appear on the front page or within categories show links to the posts themselves.

The plugin assumes that you are calling the wordpress function wp_head(); in you template header. This is so that a link for the javascript can be placed in the header. If you are not calling this function, then it’s a simple case of placing this code in the header:

<?php wp_head(); ?>

Once that is done, all you need to do is to drop the plugin into the plugins folder and enable it. Download the plugin here.

I’d be very grateful if anyone has any critism about it, or how it could be improved. If not please raise a beer to my first wordpress plugin (and my 100th post).

6 Comments

  1. Is there any way of making this plugin only pop up the box on posts that are older then X amount of days? I use a plugin (details here http://www.newmedias.co.uk/featured/hide_date_on_old_posts/ ) which also allows me to put an if statement around adsense code and display adsense on posts X days por older.

    I tried modifying your plugin as follows…

    if(is_old_post)
    add_filter(‘the_content’, ‘injectJavascript’, 250);
    add_action(‘wp_head’, ‘addIhamJavascript’);

    It kind of works but sometimes throws an error in IE.

    I basically want to only make your plugin work on images that are over 10 days old.

    Comment by Matthew — March 16, 2009 @ 3:35 pm

  2. Hi Matthew

    I’m looking for suggestions to improve the plugin, so I’ll keep this in mind when I release the next version.

    Joe

    Comment by Joe Brewer — March 16, 2009 @ 4:13 pm

  3. Does this work on multiple browsers (i.e. Firefox, Internet Explorer, Google Chrome, Safari)? Does this have any effect on the alt and title tags for images or do they retain their SEO value?

    Blessings,
    Wendy

    P.S. I don’t drink beer but I’ll raise my glass of peach tea to ya’!

    Comment by Wendy Merritt — March 21, 2009 @ 11:51 pm

  4. Hi Wendy

    I’ve only tested with IE and Firefox, and they both work well. The alt and title tags are not changed, so this will not have any effect on any on page SEO.

    Joe

    Comment by Joe Brewer — March 22, 2009 @ 7:32 am

  5. […] Image Hotlink Advantage Maximizer – Displays a link that a user can copy and paste when right clicking on an image. Let people use your images and get links back to your website and protect your images from hotlinking. Right click on the image below to see it in action. […]

    Pingback by Who Else Wants A Highly Optimized Wordpress Blog That Makes Money?- Derby SEO Company | F.M.S — August 17, 2009 @ 8:59 am

  6. […] Image Hotlink Advantage Maximizer – Displays a link that a user can copy and paste when right clicking on an image. Let people use your images and get links back to your website and protect your images from hotlinking. […]

    Pingback by FMS SEO » Wordpress Plugins For Search Engine Optimisation — January 11, 2010 @ 8:08 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress