To disable right-click on a WordPress site, cancel the browser’s contextmenu event with JavaScript. The supported WordPress implementation is to place that code in a front-end JavaScript file and load it with wp_enqueue_script() on the wp_enqueue_scripts hook. If you do not want to edit theme files, a maintained plugin can apply the same behavior to images or to the whole site.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
This is a deterrent, not security. Public images, video and other browser-delivered files remain reachable through direct URLs, caches, disabled JavaScript, developer tools, extensions, screenshots and other browsers. Choose the narrowest scope that meets your goal, then test galleries, lightboxes, video, mobile touch, keyboard navigation and assistive-technology workflows.
As an Amazon Associate I earn from qualifying purchases.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
What right-click blocking actually does
When a visitor right-clicks, the browser normally dispatches a cancelable contextmenu event and opens its menu. A listener can call preventDefault(), telling the browser not to perform that default action. The smallest working example is:
document.addEventListener('contextmenu', (event) => {
event.preventDefault();
});
This affects the context menu in the page where the script runs. It does not remove the underlying image or video, change its URL, encrypt the file or create an authorization check. Anyone who can view an asset in a browser can potentially obtain it by another route.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Firefox’s Shift exception
Firefox documents an exception: holding Shift while right-clicking can open the menu without firing contextmenu. A handler therefore cannot promise identical behavior in every browser or input combination.
Decide what you are trying to stop first
“Disable right-click” can describe several different objectives. A photographer may only want to discourage a visitor from choosing Save image as. A portfolio owner may want to protect one gallery while leaving the rest of the site unchanged. A membership site may actually need to prevent unauthorized downloads. These are not equivalent requirements.
Recommended Free Tools
Right-click suppression addresses only the first, casual-copying scenario. If the requirement is authorization, the asset must be delivered through a server-side control such as private storage, authenticated access or an expiring download mechanism. Adding more browser event handlers does not turn a public URL into a private one. Write down the objective before choosing a plugin or adding code; otherwise a broad blocker can create a large usability cost without meeting the real requirement.
Choose the least disruptive implementation
| Approach | Scope | Best use | Main trade-off |
|---|---|---|---|
| Image-only plugin | IMG elements |
Discouraging casual saving while preserving normal link menus | Some galleries can override it; directly opened image files are outside its control |
| Selected-container script | Images or components carrying a chosen class | Protecting a portfolio, gallery or download-free section | Requires adding the class consistently and maintaining the selector |
| Site-wide script or plugin | Document-level context menu | A site that accepts broad interference with browser menus | Can disrupt links, galleries, video controls, scrolling, keyboard workflows and assistive technology |
| Component-native controls | One player, gallery or embed | When a component supplies its own download or interaction settings | Settings differ by component and do not protect unrelated assets |
Compare options on five axes: scope, deployment method, compatibility, user impact and deterrence strength. Scope tells you whether the handler covers one image, a container or the entire document. Deployment may be a plugin, a custom enqueued file or a component’s own setting. Compatibility includes galleries, lightboxes, video players, iframes, browsers and mobile devices. User impact includes links, scrolling, keyboard use, assistive technology and administrator access. Deterrence strength is not the same as access control; all of these front-end options remain bypassable.
For most content sites, image-only or element-level protection is the safer starting point. A site-wide block should be a deliberate usability decision, not a default security measure.
Disable right-click with a custom WordPress script
WordPress recommends registering and loading front-end JavaScript through wp_enqueue_script(). This lets WordPress manage dependencies and the script’s loading strategy instead of placing an inline snippet in an arbitrary template file.
1. Create a maintained JavaScript file
In a child theme or a small site-specific plugin, create a file such as assets/js/context-menu.js and add the document-level listener:
document.addEventListener('contextmenu', (event) => {
event.preventDefault();
});
Keeping the code in a versioned file makes it easier to disable, update and troubleshoot than scattering JavaScript through page templates or a page builder. A site-specific plugin is independent of the active theme, while a child theme is convenient when the behavior belongs to that theme. In either case, keep a backup and record the original location so another administrator can remove the behavior later.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
2. Enqueue it on the front end
Add the following PHP to your child theme’s functions.php or, preferably for theme-independent behavior, to a site-specific plugin:
function mysite_disable_context_menu() {
wp_enqueue_script(
'mysite-context-menu',
get_stylesheet_directory_uri() . '/assets/js/context-menu.js',
array(),
'1.0.0',
array(
'in_footer' => true,
)
);
}
add_action('wp_enqueue_scripts', 'mysite_disable_context_menu');
If the file lives in a plugin rather than a child theme, build its URL from the plugin directory instead of get_stylesheet_directory_uri(). Keep the handle unique, increase the version when you change the file, and use the footer or an appropriate loading strategy so the script does not unnecessarily delay rendering.
Free tools Windows power users keep installed
One-click scans. No signup required.
The enqueue hook is for the public site, not the dashboard. That distinction matters when editors need to work normally in the administration area. If you need the behavior on only one content type, keep the enqueue function on the same hook but wrap it in a conditional. A conditional is easier to reason about than loading a global script and trying to undo it on selected pages.
3. Limit loading when the block is not site-wide
If only a particular template needs protection, conditionally enqueue the file with a WordPress conditional such as is_page(), is_singular() or a custom taxonomy check. The condition should match the content you intend to protect; loading a global blocker and trying to exempt pages later is more error-prone.
4. Clear caches and verify the delivered file
- Save the PHP and JavaScript files.
- Purge any WordPress, hosting, CDN and browser caches that may still contain the old script.
- Open a public page in a private browser window and confirm the JavaScript file appears in the page’s network or source output.
- Test a normal link, an image, a gallery, a video control and a touch device before enabling the behavior broadly.
If the file is not requested, check the hook name, PHP syntax, file path, child-theme activation and browser console. A JavaScript error elsewhere on the page can also prevent later code from running. If the file is requested but the menu still appears, check whether the interaction occurs inside an iframe or on an element created after the listener was attached.
Protect selected images or a container instead
Document-level listeners affect every element. To reduce interference, attach the listener only to marked images:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallfor (const image of document.querySelectorAll('.protected-image')) {
image.addEventListener('contextmenu', (event) => event.preventDefault());
}
Add class="protected-image" to the images you want to deter copying. A gallery wrapper can be targeted in the same way:
const gallery = document.querySelector('.protected-gallery');
if (gallery) {
gallery.addEventListener('contextmenu', (event) => {
event.preventDefault();
});
}
Element-level handling preserves the context menu on ordinary navigation and unrelated content. It is also easier to exempt an editor, a download area or an interactive widget. It does require consistent markup: an image added later by a gallery script will not be covered by a loop that ran only once at initial page load.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
For dynamic galleries, put the handler on a stable wrapper when possible, or add the listener when the component creates the new image. A wrapper-level listener can cover descendants that appear later, but it may also affect controls inside that wrapper. Check the actual element that receives the event rather than assuming the thumbnail, enlarged image and overlay are the same node.
Use a plugin when you do not want to edit code
Image-only option
The WordPress.org listing for No Right Click Images describes protection for IMG tags while leaving ordinary link right-click actions available. It can be disabled for logged-in users, which is useful for administrators and editors. The listing states that directly opened image files are outside WordPress’s protection and characterizes the feature as a deterrent to casual theft rather than a way to keep web images from being stolen.
That listing reported more than 20,000 active installations, version 4.1, a last-updated date of 2025-08-11 and testing up to WordPress 7.1.3 in its 2025/2026 entry. These figures describe that listing at the stated time; check the current plugin page and compatibility information before installing. The image-only scope is a useful fit when visitors still need normal context menus on links, text and navigation.
Site-wide option
Disable Right Click & Content Copy Protection advertises document-wide context-menu blocking, copy-shortcut blocking, image-drag protection and post-type targeting. Its listing warns that technically skilled visitors may bypass those controls. Because it blocks more interactions than an image-only tool, test every public template, editor role and interactive component before activating it.
Copy-shortcut and drag blocking are separate decisions from cancelling contextmenu. They can affect keyboard users and ordinary workflows even when no image is involved. If a plugin exposes separate switches, begin with the smallest feature set and add another control only when you can test an equivalent way for visitors to complete the task.
Plugin installation and rollback
- In the WordPress dashboard, open Plugins > Add New Plugin.
- Search for the exact plugin name, inspect its author, update date, tested WordPress version, changelog and support activity.
- Install and activate it, then open its settings page if one is provided.
- Choose image-only, selected-content or site-wide scope. Prefer the narrowest setting that meets the goal.
- Use any “disable for logged-in users” or administrator exclusion so you can maintain the site normally.
- Test public pages in multiple browsers and on a phone. If a gallery, player or navigation control fails, deactivate the plugin and restore normal behavior before investigating a narrower configuration.
Keep a recent backup and record the previous setting. A plugin can be deactivated from Plugins > Installed Plugins if it causes a conflict. If the plugin has not been updated recently or its support area shows unresolved compatibility problems, do not assume a right-click blocker is worth adding another maintenance dependency.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Why a blocker fails on videos, galleries and embeds
Third-party iframes
A script in the parent WordPress page cannot control the document inside a third-party <iframe>. This is why a right-click blocker may work on the page around an embedded video but not on the player itself. A WordPress support explanation notes that iframe-based video initialization can keep the handler away from the player; switching to a JavaScript-based initialization mode can allow the site’s script to interact with the player, when that player supports such a mode.
For an external iframe you do not control, use the provider’s own configuration or accept that the embedded document has separate behavior. Do not attempt to inject code across origins. Also remember that a player may intentionally need its own context menu for captions, playback controls or accessibility features; blocking it without a replacement can make the video harder to use.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Galleries and lightboxes
Gallery and lightbox scripts often install their own pointer handlers, replace images, or open a new overlay element after the page loads. A plugin may protect the original thumbnail but not the enlarged image, or the gallery may override the plugin’s event. Apply protection to the element that actually receives the interaction, and retest after the gallery initializes.
Some galleries also use an image as a link or as the drag surface for a carousel. Suppressing its menu can be harmless on desktop but interfere with a touch gesture or with the user’s ability to open the linked image. Test thumbnails, full-size overlays, captions, next and previous controls, and any download button separately.
Clickable images and mobile scrolling
An image that is also a link needs its normal activation behavior. On touch devices, long-press menus and gesture handling are different from a desktop right-click. A broad blocker can make a large clickable image feel unresponsive or interfere with scrolling. Test short taps, long-press, pinch or gallery swipes and the browser’s back gesture before release.
What right-click blocking cannot prevent
- Direct asset URLs: The image or video must be sent to the browser, so its URL can often be found in page markup, network requests or a media library.
- Disabled JavaScript: With scripts disabled, the browser’s normal menu is available.
- Developer tools and caches: A visitor can inspect requests, retrieve cached resources or use an extension.
- Alternate browsers and input methods: Browser-specific behavior, keyboard commands and assistive technology do not depend on your preferred mouse handler.
- Screenshots and recording: A deterrent cannot stop a visitor from capturing what is displayed.
- Files opened outside your page: A directly opened image URL is no longer inside the WordPress page where your listener runs.
Use server-side authorization, private storage, expiring downloads or a rights-management workflow when the requirement is actual access control. A front-end event handler cannot provide those guarantees. Watermarks, licensing notices and clear terms may support a rights-management process, but they do not replace access controls when files must remain private.
Accessibility and user-experience checks
JavaScript that removes a familiar browser function can harm accessibility when it has no equivalent path. MDN recommends device-independent interaction and accessible alternatives when scripting changes default behavior. Before publishing a blocker, run this checklist:
- Navigate the page with the keyboard, including links, menus, dialogs and gallery controls.
- Use a screen reader to reach image links, captions, controls and any download instructions.
- Test touch, long-press, scrolling and orientation changes on a phone and tablet.
- Open and operate lightboxes, carousels and video controls.
- Confirm that editors and administrators can still inspect and maintain content, or enable a logged-in exclusion.
- Check ordinary link context menus and any browser workflow your audience relies on.
- Do not block keyboard shortcuts or developer tools unless there is a documented reason and a tested alternative.
Ask someone who uses keyboard navigation or assistive technology to perform the same tasks as a typical visitor. A page can appear visually correct while its controls become difficult to discover or operate. If the only benefit is making one menu item less convenient, the resulting friction may not justify the change.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsIf any essential workflow breaks, reduce the scope from document-wide to image-only or a selected container, or remove the blocker. Preserving navigation and access is usually more valuable than deterring a determined copier.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common problems
The script never runs
- Confirm the enqueue function is attached to
wp_enqueue_scripts, not an admin-only hook. - Check that the file URL and case-sensitive path are correct.
- View the page source or network panel to verify the file is delivered.
- Look for PHP errors, a failed dependency or a JavaScript syntax error.
- Purge page, CDN and browser caches after changes.
It works on some images but not others
Inspect whether the protected image is injected after page load, replaced by a lightbox or inside an iframe. A direct listener on initial IMG elements will not automatically cover later replacements. Delegate from a known container, add the listener when the gallery creates the element, or use the component’s own setting.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
It blocks too much
Replace the document listener with a selector-based listener, disable copy-shortcut and drag blocking, or configure an image-only plugin. Exclude logged-in users and test each content type again.
Visitors can still save the image
That is expected. Right-click suppression only removes one convenient browser action. It does not hide the file or prevent alternate extraction methods. If preventing unauthorized downloads is essential, redesign delivery around authenticated or expiring URLs rather than adding more client-side traps.
The blocker works on the page but not the video
Determine whether the player is rendered in an iframe. If it is a third-party document, the parent page’s listener cannot reach it. Check the provider’s settings or, when supported, use a JavaScript-based initialization mode that keeps the player interaction within a document you control.
A practical rollout plan
- Write down the actual objective: discourage casual image saving, protect one gallery, or enforce authenticated downloads.
- If the objective is deterrence, start with a selected-container or image-only approach.
- Implement it through an enqueued, maintained script or a plugin with current updates and a clear rollback path.
- Exclude logged-in administrators and editors where possible.
- Test desktop browsers, Firefox’s Shift-right-click behavior, keyboard use, mobile long-press, galleries, lightboxes, video and iframes.
- Review support requests and analytics for broken interactions after launch.
- If the usability cost exceeds the deterrence benefit, narrow the selector or remove the blocker.
Bottom line for WordPress site owners
The technical answer is simple: cancel contextmenu and load the script with wp_enqueue_script(). The responsible answer is narrower: protect only the images or component that needs a casual-copy deterrent, leave normal navigation and accessible controls intact, and treat every public asset as retrievable. No plugin or JavaScript snippet turns a browser-delivered file into a private one.
Frequently Asked Questions
How do I disable right-click on my WordPress site without a plugin?
Create a front-end JavaScript file containing a contextmenu listener that calls preventDefault(), then enqueue it with wp_enqueue_script() on wp_enqueue_scripts. Put the code in a child theme or site-specific plugin rather than an arbitrary template. For limited protection, attach the listener to selected images or a container instead of document.
Can I stop visitors from saving my WordPress images?
You can discourage the ordinary right-click save action, especially with an image-only plugin or selector-based script. You cannot make a public image impossible to obtain. Direct URLs, browser caches, disabled JavaScript, developer tools, extensions, screenshots and alternate browsers remain available.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Why does right-click blocking fail on my embedded video?
A third-party iframe is a separate document, so a script in the parent WordPress page cannot control its context menu. Use the video provider’s own settings, or switch to a JavaScript-based initialization mode when the player supports one. Do not inject code across origins.
Should I use an image-only or site-wide plugin?
Use image-only protection when normal right-click behavior on links, navigation and text matters. Choose site-wide blocking only when you accept broader interference and have tested every template, gallery, player, browser and mobile workflow. A site-wide setting does not provide stronger file security.
Will Firefox users still be able to open the context menu?
Firefox documents that holding Shift while right-clicking can open the menu without firing the contextmenu event. A handler therefore cannot guarantee identical behavior for every browser and input combination.
How can I undo a right-click blocker that breaks my site?
For custom code, remove or conditionally disable the enqueued script and purge caches. For a plugin, deactivate it from Plugins > Installed Plugins, then restore a narrower setting if appropriate. Test galleries, lightboxes, video controls, keyboard navigation, touch gestures and administrator access before trying again.
Recommended Free Tools
The Bottom Line
Use contextmenu suppression only as a narrow deterrent. Enqueue the script through WordPress, prefer image or component scope, test accessibility and interactive media, and use server-side controls when the files truly need protection.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




