Reputation: 131
It is good that magneto offers watermarking of images so a watermarked image will appear as
http://www.yourwebsite.com/media/catalog/product/cache/1/image/de684549e4151748e56ee0dd7902c19f/m/y/my-first-image.jpg
This is good. But if anyone removes the cache/1/image/de684549e4151748e56ee0dd7902c19f part of URL so that it becomes
http://www.yourwebsite.com/media/catalog/product/m/y/my-first-image.jpg
He can view the image and copy it. What is best way to cope up with this problem?
Upvotes: 0
Views: 1266
Reputation: 131
This is how I managed to do it.
Put an .htaccess file in media/catalog/
folder in Magento with following code in it
Options +FollowSymLinks
RewriteEngine on
#Following line allows the actual images to be accessed by admin end directly
RewriteCond %{HTTP_REFERER} !^http://www.yourwebsite.com/.*$ [NC]
#Following line allows the watermarked images to be accessed directly. Rule says that if URL does not contain cache
RewriteCond %{REQUEST_URI} !(/cache/) [NC]
#This is the page where visitor will be redirected if tries to access images directly.
RewriteRule \.(gif|jpg)$ http://www.yourwebsite.com/do-not-try-to-steal-images.html/ [R,L]
Upvotes: 1
Reputation: 1570
You can create an .htaccess file in the media/catalog folder with the following lines in it:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*?/cache.*)$ $1 [L]
RewriteRule ^(.*)$ $1 [F]
This will return a 403 to the user if they try to view the original file but let them see the images that are in the cache.
This breaks previewing the images in the admin as they display the original files and not a generated thumbnail.
Upvotes: 0
Reputation: 2466
Well, create yourself your images with the watermark !!! Like that if the cache is deleted, the cache will recreate an image from the already watermarked image
Upvotes: 0