Prevent images from being copied with a simple WordPress code

Prevent images from being copied with a simple Wordpress code


How to prevent simple image copying in WordPress?

1. Should the copying of images on the web be prevented?

It depends on the intended use of the website.

2. How to prevent images from being copied on the website

Method 1: Insert the anti-copy image code into the website.

Method 2: Enable dynamic link protection in cPanel.

Now Method 1 If you are using a plugin to help you insert code into WordPress, such as Insert headers and footers Then go to the plugin settings. Insert the above code in the footer, before the closing tag


script type=”text/javascript>
function no context(e) {
var clickedTag = (e==bad) ? an event.srcElement.tagName :;
if (clickedTag == “img”)
come back fake;
document.oncontextmenu = no context;
image {
-webkit-user-drag: nothing;
user-drag: nothing;
-webkit-touch-legend: nothing;

Where you enter Display > Modify interface. Select the correct interface you are using, find the file named Theme footer (footer.php) To fix.

Then comes method 2:

You enter cPanel, then search for the item Protecting dynamic links.

Here is the list of domains available in your hosting. Just click on the button Enable is to be.

That’s it, try to open an image file link in a window incognito browser to check if 403 is returned. Because if you open it with your current browser, the browser can still cache the image, so it still displays the image.


With just the simple code above, you can prevent image copying with simple WordPress code.

If you find it interesting, you can follow the wordpress tips section to learn more new knowledge.

Follow the fanpage to receive the latest articles: Hocwordpress Group

I wish you to have interesting and interesting knowledge about wordpress!


Rate Items


Recommended Posts