Stealing images from your website is easy because a user can simply right click and select ‘save image as’ to download them. You can disable right click on your website and make it more difficult for an average user to steal your image.
The easiest way to do this in MotoCMS is by using the following code in Settings - Code Injection section:
<script type="text/javascript">
function nocontext(e) {
var clickedTag = (e==null) ? event.srcElement.tagName : e.target.tagName;
if (clickedTag == "IMG")
return false;
}
document.oncontextmenu = nocontext;
document.addEventListener('contextmenu', event => event.preventDefault());
</script>
<style media="screen" type="text/css">
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
Please note! Some of admin panel features might work incorrectly after adding this code. You can disable execution of all code added to Code injection sections so the code will run on site preview, but won't be executed in admin panel.
Comments