# Discourage Copying Images and Text

> Disables right-click and dragging on images, and optionally text selection in post content, to discourage casual copying of your work.

- Type: HTML
- Runs: Site-wide footer
- Category: [Frontend & Design](https://wpide.com/library/category/frontend/)
- Tags: protection, images, copy, javascript
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/frontend-content-protection/

## Code

```html
<script>
(function () {
    var blockTextSelection = false; // true: also prevent selecting text in post content.
    document.addEventListener('contextmenu', function (e) {
        if (e.target.tagName === 'IMG') { e.preventDefault(); }
    });
    document.addEventListener('dragstart', function (e) {
        if (e.target.tagName === 'IMG') { e.preventDefault(); }
    });
    if (blockTextSelection) {
        var style = document.createElement('style');
        style.textContent = '.entry-content,.wp-block-post-content{-webkit-user-select:none;user-select:none;}';
        document.head.appendChild(style);
    }
})();
</script>
```

## Notes

This only deters casual copying; anything shown in a browser can still be saved. Text selection is left on by default for accessibility.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Discourage Copying Images and Text" in its snippet library and add it in one click; or create a new HTML snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
