0

My site contains a lot of custom images. I've searched the web and found a lot of websites that link directly to the images on my site. Meaning, they link to the jpeg itself, not to the actual page on my site that contains the jpeg. When someone clicks the link, it only shows the image against a blank page background. There is no site content.

I'd like when someone clicks the link on the other site that it opens the image on a page with my main menu, etc. so they can navigate my site.

Is there any way to do this?

Disclaimer: I realize this may sound like a naïve question, and that when someone links to an image, there would be no way to know if they were linking to the image from within a page, or to the image directly. But I'm wondering if someone has found a work-around, such as, if the image link is coming from an external site... etc.

  • 1
    You can always stop image leaching. That way nobody will be able to direct link your images in their website. – Sabbir Hasan Oct 3 at 6:40
  • That's an option, but seems like a last resort. How can I configure this in WordPress? – Francisco d'Anconia Oct 3 at 16:55
  • Check my answer below. You will need some skill to achieve this. – Sabbir Hasan Oct 3 at 18:59
0

You need to edit .htaccess file and add following line right after current lines. You can edit the file from cpanel or FTP. Also there is a WordPress Plugin that allows to edit .htaccess file.

Remember it's a very advanced thing to do. So make sure to backup current file before editing. Any error will cause site not loading.

/* Prevent image hotlinking in WordPress */
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourwebsite.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?twitter.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [F]

This will let only youtube, google, facebook and twitter to directly Link you images. All other websites will be blocked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.