Latest news

How To Protect Original Product Images In Magento 2?

1 comment

PROBLEM:

The developer enables the watermark function of Magento 2, but the original product images are still accessible from URL without the watermark.

For example:

Cached image URL with the watermark:

/pub/media/catalog/product/cache/df484df48ez74849c15sd4f7780/f/f/dsf-8f48d4f.jpg

The original image URL without the watermark:

/pub/media/catalog/product/f/f/dsf-8f48d4f.jpg

Therefore, if someone who removes /cache/df484df48ez74849c15sd4f7780/ from URL can still access to the original photo without watermark to steal the images.

How can the developer protect his original product images?

SOLUTIONS:

The simple solution here is modifying and using the following .htaccess file in the /var/media/catalog directory:

Options +FollowSymLinks
RewriteEngine on

#The next coding line permits the original images to be accessed by admin end directly

RewriteCond %{HTTP_REFERER} !^http://www.yourwebsite.com/.*$ [NC]

#The next coding line permits the watermarked images to be accessed directly. It is according to the rule where the URL does not contain a cache.

RewriteCond %{REQUEST_URI} !(/cache/) [NC]

#It is the page where your store visitor will be redirected if they will attempt to access images directly.

RewriteRule \.(gif|jpg)$ http://en.wikipedia.org/wiki/You_shall_not_steal [R,L]

The above security measure will help the developer to prevent his Magento product images from being stolen, downloaded and copied.

We have shown you an easy way to protect the original image files in Magento 2. If you have any problems when following the instruction, please leave a comment below. See you in the next tutorial!

See More:

[Fix It Series] Magento 2 Error: Custom Links in Admin Menu CE 2.1.8

Magento 2 Tutorials – From A to Z For Beginners

Top 10 Tigren Magento Blog Posts From 2017

War Of The Best Magento Mobile App: Why Magento Hybrid App Is Killing Magento Native App?

5 Common Misconceptions About Magento PWA

Why We Love Progressive Web App For Magento (And You Should, Too!)

 
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Loading...

April LeeHow To Protect Original Product Images In Magento 2?

Related Posts

1 comment

Join the conversation
  • Syed Muneeb Ul Hasan - January 19, 2018 reply

    Thanks for providing a great solution to protect the original product images!

Leave a Reply

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