0

Most of the images on my site are svg and I would like to protect them somehow.. I tried with block right click but when you drag the photo in an new tag appear the link my svg image.. how could I restrict that?

I tried with .htaccess but nothing.. i dont success.. anyone can help me with some advices?

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mysite.com [NC]
RewriteRule \.(jpg|jpeg|png|svg)$ - [NC,F,L]
Tolios
  • 219
  • 3
  • 12
Teodor
  • 51
  • 4
  • 5
    Realistically, you can't - if you're showing them to the user, you're giving them to the user ... hell, they might even be able to go digging about in their browser cache if they're bored enough. – CD001 Jul 15 '19 at 10:53
  • may be worth reading: https://stackoverflow.com/questions/44310801/how-to-disable-view-source-and-inspect-element && https://stackoverflow.com/questions/1037593/how-to-disable-view-source-and-ctrl-c-from-my-site – treyBake Jul 15 '19 at 10:57

2 Answers2

1

There is no way you can protect your SVG files: If you want to show SVG files on a website, you are giving the source code for the client.

The only way to "protect" HTML, CSS, SVG or JavaScript files is to obfuscate them, but that won't help too much with SVG files as you can edit them in Inkscape or similar graphical tool anyway.

Disabling clicks for example by adding transparent layers over your "protected" SVG images will only make it harder for some non-technical users to grab your SVG code, but other than that there is no way you could "eat your cake and save it too" -- if you show the SVG image, the client gets the source code.

You could also export SVG images as bit map images like PNG, if the original scalable image is what you are trying to protect, but that way you lose all the flexibility SVG is used for.

0

You cannot prevent another party from viewing your source code or even copying it to their computer. However, if they then take that code and the image it produces and start using it for commercial purposes or sell it to someone else, then you have a copyright violation and can file a lawsuit against them. It isn't illegal to see or copy the code that produces an image, it is illegal to reuse that code without permission (if permission was originally indicated).

KDS112
  • 1