WordPress hotlink prevention plugin

by Joe Brewer on March 15, 2009

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

Be Sociable, Share!

{ 2 trackbacks }

Who Else Wants A Highly Optimized Wordpress Blog That Makes Money?- Derby SEO Company | F.M.S
August 17, 2009 at 8:59 am
FMS SEO » Wordpress Plugins For Search Engine Optimisation
January 11, 2010 at 8:08 am

{ 4 comments… read them below or add one }

Matthew March 16, 2009 at 3:35 pm

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.

Joe Brewer March 16, 2009 at 4:13 pm

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

Wendy Merritt March 21, 2009 at 11:51 pm

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’!

Joe Brewer March 22, 2009 at 7:32 am

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

Leave a Comment

CommentLuv badge

Previous post:

Next post: