Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


How can I stop people stealing my blog images and photos?

Is there a command I can use to stop people right clicking and saving copies of my images? I get annoyed when they take my work and post it on their website without permission. Thanks.


Dave's Answer:

This is a bit of a sticky question because it's just about impossible to stop people from getting to your image if they really, really want to. I'll show you a couple of ways to make copying images harder, but just like any other approach to security, it makes things more difficult, not impossible.

For example, you can take a screenshot or screen capture and then trim it down in a graphics editor to get a specific image, even if the image is locked up and hidden away on a page. You could also unwind and decipher the HTML source code to ascertain the URL of a specific image and simply request that URL directly in your browser, thereby sidestepping anything to do with a hiding technique.

But let's look at how to make things more difficult, then I'll suggest a couple of different ways you can perhaps gain advantage by not trying to block people copying your content...

The first and most common way to stop people copying images is to disable the right-click (or, if you're on a Mac, control-click) pop-up menu in the Web browser. There are a variety of different Javascript code solutions floating around, but here's one I tested that worked across just about all the browsers I could try:

<script>
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape")
document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
  return false;
}
function mousehandler(e){
  var myevent = (isNS) ? e : event;
  var eventbutton = (isNS) ? myevent.which : myevent.button;
  if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
</script>

You can see this in action by trying to right-click or control-click on the following image:

American Flag Icon

No menu should pop up (though I believe that this doesn't work in MS IE7)

The problem is, you can still drag the image off your browser screen and drop it onto your Desktop, thereby copying it. But we can address that too with a CSS trick this time: put the image in a single cell table as the background image:

<table>
<tr>
<td style="width:192; height:146; background-image: url(american-flag.gif)">
&nbsp;
</td>
</tr>
</table>

This works by putting the image "behind" all the content on the page, but it's ugly and you have to be sure you have exactly the right dimensions of the image. Nonetheless, try it here:

 

So between the Javascript and the CSS tricks, we've made it quite a bit harder to informally steal the American flag image on this page, which might slow down "drive-by copiers", which might be sufficient for what you need, but it's just a matter of a few seconds to read the source and identify the actual URL of that image (which is http://www.askdavetaylor.com/1-blog-pics/american-flag.gif if you're curious) and bring that image up by itself, and then steal it anyway.

Instead, I suggest that you might want to consider either adding a watermark to your image and not worrying about it, or actually encouraging people to rip off the image by supplying some HTML code immediately below the image, code that includes a link back to your site!

Here's how the first might look:

American Flag Icon: Watermarked

Personally, I find this to be an invasive and rather ugly solution, where everyone who visits the site has to suffer through the anti-piracy measures that you have in place for the precious few who would act inappropriately, so I'm not a fan.

The final way you might deal with the problem is to have a small code box immediately under the image that encourages people to take it including a link back to your site as the source of the image.

Here's an example of how that might look:

American Flag Icon

Add This Image To Your Site: Use our handy HTML code.

Not too horrible, fairly low key, and if they grab all the HTML code, you get a nice backlink for their effort, which is a good thing. Unwrap it all and here's the source code to the above:

<img src="http://www.askdavetaylor.com/1-blog-pics/american-flag.gif" alt="American Flag Icon" /><div style="font-size:85%;"><form><textarea rows="1" cols="40" style="font-size:85%">&lt;img src="http://www.askdavetaylor.com/1-blog-pics/american-flag.gif" alt="American Flag Icon"&gt;&lt;div style="font-size:75%">Image source: &lt;a href="http://www.askdavetaylor.com/">AskDaveTaylor.com&lt;/a>&lt;/div></textarea><br />Add This Image To Your Site: Use our handy HTML code.</div>

So that works, it's nice, but, blech, what a complicated way to add an image. A lot harder than just using the ole' Flickr copy and paste function!

That gives you all the major ways you can solve your image theft problem. I leave it to you, dear reader, to decide which of them, or which combination of them, will work best for you when considering both the effectiveness of the approach and the level of additional work involved in adding images to your site or blog.


More Useful HTML, JavaScript and Web Site Programming Articles:
✔   How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔   Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔   Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔   How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔   How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  




Categorized: HTML, JavaScript and Web Site Programming   (Article 7942, Written by )
Tagged: flickr, image theft, intellectual property
Previous: How can I get songs off my Apple iPhone?
Next: How can I read a password without echoing it in C?




Reader Comments To Date:

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!
Rather amazingly, there are no comments on this article yet.

I do have a comment, now that you mention it!











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.