Wordpress image hotlink plugin

Sometimes, when you are building a blog that is all about pictures, you want to give people any easy way to include those images in your own site and you don’t mind if they hotlink them (i.e. leech off your hosting) as long as you get a link back for your efforts.

I was building a site that needed exactly this functionality this weekend and, after a bit of searching around, I found Patrick Altoft’s Google Images hotlink wordpress plugin which did nearly what I wanted it to. Whenever a visitor comes from Google Images (or other search engines’ image searches) it pops up an instruction dialog box with code for embedding the image and linking back to the original post. Note that it only does this on individual post pages - not on images displayed on the homepage, category pages etc.

I wanted to do exactly that, but for all visitors - not just those from image searches.

Luckily, due to the open nature of the platform and the fact that Patrick released his plugin under the GPL, I was able to modify it to do my bidding. Since it’s all about the community, I am releasing my efforts here in case anyone wants to do the same thing as me:

So I’m happy to present my first wordpress plugin (even though it’s a modified version of Patrick’s - who I spoke to before releasing): hotlink builder. The linked zip file contains a file named hotlink-builder-distilled.php that should be placed in your ‘plugins’ folder (in wp-content) if you are running a wordpress blog. You will then be able to activate it from the plugins tab within the wordpress admin area and modify the default bit of text from the configuration link.

The zip file also contains a readme.txt file as per the wordpress guidelines that contains instructions etc. I hope you find it useful!

Here is an example of the information dialogue it places on the page when someone right-clicks on an image:

plugin-screenshot.png

Will Critchlow

Will Critchlow

Will founded Distilled with Duncan in 2005. Since then, he has consulted with some of the world’s largest organisations and most famous websites, spoken at most major industry events and regularly appeared in local and national press. Will is part...   read more

Get blog posts via email

19 Comments

  1. Very cool expansion of the original functionality. I've been considering Blogstorm's plugin but this is even better. I'll take a look!

    reply >
  2. thanks, you are really helpful.
    your information rocks!

    reply >
  3. I wouldn't say it's better than Blogstorm's functionality - just designed to perform a slightly different task. Thanks though :)

    reply >
  4. Yeah - I'd echo what Will said, you need to decide carefully which visitors you're going to show this to. Showing this to all visitors could be a problem for you depending on your site and sector etc.

    reply >
  5. Dag

    This plugin has the same problem it only is working on the first image in the post. any idea on how to fix this problem?

    reply >
  6. Hi Dag,

    You're right - it will still work that way. I didn't write the regular expression bit that actually replaces that (I only changed when it does that).

    I imagine I could change it with a bit of work, but I actually don't need that functionality, so can't guarantee when or if I might get it changed.

    Sorry. W

    reply >
  7. Dag

    I think your missing my point

    If you have 1 image in every post of 10 posts on the page and the user right clicks on the say 4th post image the box will show up in the top of the first post with a image on the page with the first posts image details not the details for the image they had clicked on.

    reply >
  8. Dag, my point is that with the way the blog I am using this plugin is set up, I don't have any pages like that - I only ever have one per page so that issue doesn't arise for me at the moment.

    I think Patrick (who wrote that bit of the code originally) might be better placed to help you out.

    reply >
  9. Interesting idea and it works fine on my home page. However, it breaks any single page post. The text around the first image as well as the first image end up at the very top above the header and menu bar! Then the rest of the content follows. Very strange. Any thoughts?

    reply >
  10. I'm having a different issue and I'm not sure if it stems from using WP 2.3 or not. The plugin works perfectly, only, too well. I can't right click any hyperlink-including text, (example, the title to a post or a link within a post), without the pop-up box showing. I only want this to work for images, not every hyperlink on my site. Any suggestions?

    reply >
  11. Hi Beth,

    Testing a bit more, that problem happens for me as well....

    I think that's from the original (i.e. I'm not sure I introduced that problem). I will try to take a look at what is going on with the code that captures the right-click at some point. It might take me a while. Sorry about that.

    reply >
  12. alex

    This would be such a great plugin, if only the bugs would be fixed !

    This plugin does not work with the post excerpts plugin, causing full pages to be shown on the homepage, etc. This is a huge problem for me, and I'm sure lots of other people.

    Think this can be looked at and fixed?

    reply >
  13. Hi Alex,

    I think that's the original plugin that needs those changes putting in - my changes are simply to change the reliance on referrers. Unfortunately, I think you need to speak to the original plugin author about those issues.

    Thanks
    Will

    reply >
  14. Will,

    Even "as is" - thanks! It's great stuff!

    Two things to knock this plugin "out of the park":

    (1) (As already mentioned here:) if it could be made so it works on a page with multiple images. On my Scudfish I display many images on the index, archive and category pages... :-(

    (2) An option to display a message when an image is hovered, to bring attention to the fact that the option to copy the code is there. Preferebly a message that doesn't confuse (isn't visible to) search engines etc.

    Again, thanks! It's very nice of you to make this available to coding challenged people like myself.

    Risto

    reply >
  15. Thanks Risto. Haven't had a chance to revisit it for a while - the blog I wrote it for has got kinda neglected recently... If I get a chance to go back to it, I will take your suggestions into account.

    reply >
  16. Raj

    Is it possible to show the embedding code below each image using this plugin? if yes then could you plz let me know how to do it.

    reply >
  17. Thank you very much. That´s THE plugin for me because a lot of Blogs are using my shirt design images without linking back to my site.

    reply >
  18. sesebian

    page breaking and deterioration began.

    reply >
  19. Peter

    I run a website where I publish at 99% free wallpapers (public domain photos).
    My problem isn't others hotlinking my images because I share the original resource, so I think they hotlink that...

    My problem is, if somebody search Google for "Horse wallpapers" they do see my images because I see image.google.com as a referrer, but they see them directly and they just "right click", "save as"...

    Is there a solution to let Google Images find my pictures, but after people click on them, they are redirected to the correspondent page on my blog? ...Which means more advertisement earnings for me ... Evil muhahaha ... just kidding...

    Can somebody advise on this?

    reply >

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>