How to prevent simple image copying in WordPress?
1. Should you prevent copying images on the web?
This depends on the intended use of the website.
2. How to prevent copying images on the website
Method 1: Insert anti-copy image code into the website.
Method 2: Enable Hotlink Protection in cPanel.
Now method 1 If you are using a plugin that helps insert code into WordPress such as Insert Headers And Footers , go to that plugin’s settings. Insert the above code in the Footer, before the closing </body> tag.

| < 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 ; | |
| </ scripts > | |
| < style > | |
| img { | |
| -webkit-user-drag : none; | |
| user-drag : none; | |
| -webkit-touch-callout : none; | |
| } | |
| </ style > |
Or you go to Interface > Edit interface . Select the correct theme you are using, find the file named Theme Footer (footer.php) to edit.
Next is method 2:


You are entering cPanel and then find the Hotlink Protection section .
Here will list available domains in your hosting. You just need to click the Enable button .
That’s it, try to open the link of an image file in an incognito browser window to check if it returns 403. Because if you open it with your current browser, the browser may still cache the image, so it still displays the image.
Epilogue
With just the above simple code, you can prevent image copying with simple WordPress code.
If you find it interesting, you can follow the wordpress tips section to know more new knowledge.
Follow fanpage to receive the latest posts: Group
Wish you have interesting and interesting knowledge about wordpress!
