Enable Media Replace


A free, lightweight and easy to use plugin that allows you to seamlessly replace an image or file in your Media Library by uploading a new file in its place. No more deleting, renaming and re-uploading files! Now fully compatible with WP Offload Media!
New beta feature! You can now remove the background of your images for better integration with eCommerce solutions!
Supported by the friendly team that created ShortPixel 🙂

En riktig tidsparare

Don’t you find it tedious and complicated to first delete a file and then upload another one with the exact same name every time you want to update an image or other uploaded file in the WordPress media library?

Inte längre!

Nu kan du ersätta valfri uppladdad fil direkt i vyn ”Redigera media” (där funktionen rätteligen hör hemma). Mediafiler kan ersättas på två sätt:

Det är enkelt att ersätta en fil

  1. Simply replace the file. This option requires you to upload a file of the same type as the file you want to replace. The attachment name remains the same regardless of what the file you upload is called.
  2. Replace the file, use the new file name, and update all links. If you check this option, the old file will be replaced with the name and type of the file you are uploading. All links pointing to the current file will be updated to point to the new file name. Additional options for the folder to put the new file in or the date of the new file are also available on the replace screen.

This plugin is very powerful and a must-have for all major websites built with WordPress. It also offers a preview of the replaced image!

New beta feature: You can now remove the background of any image!

Similar to replacing media, you can also remove the background of the images from the Media Library! The background removal feature sends the images to ShortPixel’s API, removes the background and sends them back in a preview window. If everything looks good, just replace the image with the one that has the background removed! If the source image is a PNG file, you will get a transparent background, while the other images default to a solid white background. You also have the option to choose a different color with an embedded color picker.
The background removal feature is still in beta and will be free of charge for a reasonable usage.

If you don’t want to use the background removal feature, add this line to your theme’s functions.php file, or use a plugin like Code Snippets:

`add_filter( 'emr/feature/background', '__return_false' );```

A similar filter, for the remote notification system is:

`add_filter( 'emr/feature/remote_notice', '__return_false' );```

To shorten the wait time before redirecting to the media editing screen, use the following filter and specify the wait time in seconds (0 means that redirection is immediate, but may cause problems in certain configurations):

`add_filter('emr/success/timeout', function () { return 3; });```

Visa tiden för filändringen

There is a shortcode that takes the file modification date and displays it in a post or on a page. The code is:
[file_modified id=XX format=XXXX] where the ”id” is required and the ”format” is optional and defaults to your current WordPress settings for date and time format.

So [file_modified id=870] would show the last time the file with ID 870 was updated on your site. To get the ID for a file, check the URL when editing a file in the media library (see screenshot #4)

If you want more control over the format in which the time is shown, you can use the format option. So [file_modified id=870 format=Y-m-d] would show the date the file was modified but not the time. The format string uses the standard PHP date() formatting tags.

Andra tillägg av ShortPixel:

Kontakta oss!

Wishlist / Coming attractions

Har du förslag? Kontakta gärna ShortPixel här


Want to help us improve the plugin feel free to submit PRs via GitHub here.


  • Den nya länken i mediebiblioteket.
  • ”Ersätt media”-knappen som visas i vyn ”Redigera media”.
  • Uppladdningsalternativen.
  • Get the file ID in the edit file URL


Snabb och enkel installation:

  1. Ladda upp mappen enable-media-replace till din tilläggskatalog
  2. Aktivera tillägget via menyn ”Tillägg” i WordPress.
  3. Klart!

Vanliga frågor

Where do I report security bugs found in this plugin?

Please report security bugs found in the source code of the Enable Media Replace plugin through the Patchstack Vulnerability Disclosure Program. The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.= What does this plugin actually do? =

Detta tillägg gör det enkelt att uppdatera/ersätta filer som har laddats upp till WordPress mediebibliotek.

Hur fungerar det?

A new option will be available in the Edit Media view, called ”Replace Media”. This is where you can upload a new file to replace the old one.

Jag ersatte en fil, men den ändrades inte!

Det finns två huvudorsaker till att detta skulle hända.

Kontrollera först att du inte visar en cachelagrad version av filen, speciellt om du ersatte en bild. Tryck på ”Uppdatera” i din webbläsare för att vara säker.

Second, if the file really looks unchanged, make sure WordPress has write permissions to the files in your uploads folder. If you have ever moved your WP installation (maybe when you moved it to a new server), the permissions on your uploaded files are commonly reset so that WordPress no longer has permissions to change the files. If you don’t know how to do this, contact your web server operator.


17 juli 2024 4 svar
I had dozens of images to replace and this made it sooooooo much faster! Those of us who spend hours in front of a computer making websites every day appreciate timesavers.I am very cautious about adding new plugins because they can cause issues, so I only use a few. But I added this one and I’m glad I did. It also seems to be updated by the programmers fairly often, which gives me confidence. So far, no problems, only benefits. If that changes, I’ll change my review :)Note: It would be cool if they added a feature that automatically deleted the image you’re replacing, even if you give the new one a different name. That would save even more time!
24 juni 2024 1 svar
Works great except as per below. wont replace the image if the filename is the same as the one already present in WP. Will only replace the image if the filename is diferent and the ”Replace the file, use the new file name, and update all links” option is selected.
1 april 2024 1 svar
This plugin was a real life saver. I replaced hundreds of oversized images on a large, old website with it. This plugin worked perfectly every time.(To find the largest images on the website I also installed the plugin ’Media Library File Size’ to sort images by file size.)
28 mars 2024 9 svar
Whatever they did to their code base, it isnt working on both local and production site. The support is not really helpful (just random guesses).Too bad, it was the number one replacement plugin but there are alternatives now which work without any problems.
Läs alla 290 betyg

Bidragsgivare och utvecklare

”Enable Media Replace” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.

Bidragande personer

”Enable Media Replace” har översatts till 33 språk. Tack till översättarna för deras bidrag.

Översätt ”Enable Media Replace” till ditt språk.

Intresserad av programutveckling?

Läs programkoden, kika på SVN-filförvaret eller prenumerera på utvecklarloggen via RSS.



Release date: December 14, 2023
* Tweak: Added a filter to disable the remote notification system added in version 4.1.0;
* Fix: A potential ”Reflected Cross-Site Scripting” vulnerability has been patched, responsibly disclosed by the Wordfence team.


Release date: September 22, 2023
* Fix: The latest security fix was breaking the replacements made with Beaver Builder (and possibly other builders);


Release date: September 14, 2023
* Fix: A possible PHP Object Injection was patched, which could be exploited under certain conditions;
* Fix: ShortPixel Image Optimizer handles offloading when both plugins are used with WP Offload Media.


Release date: April 24, 2023
* Tweak: Reduced the wait time before redirecting to the media edit page to half (5s);
* Fix: If an item is not offloaded, no attempt is made to update its data;
* Fix: Removed some double spaces from the plugin strings (thanks to @Presskopp).


Release date: April 13, 2023
* Tweak: Added a filter to reduce or remove the wait time before redirecting to the media edit page;
* Fix: Replacement works again on multisite setups where the plugin reported the path outside the uploads folder;
* Fix: In some cases, replacement didn’t work when images were offloaded;
* Fix: Some translation strings were corrected (thanks @alexclassroom !).


Release date: March 28, 2023
* New: Integration with WP Offload Media; items that are offloaded can now be replaced correctly;
* New: Switch to a Replacer module that improves the code and makes it more robust;
* New: Adding an intermediate confirmation page to solve possible redirection issues;
* Tweak: The new image can now be dragged and dropped directly into the preview area;
* Tweak: Improved the display of both the original image and the new image on the replacement screen;
* Tweak: Improved the notification system and added a mechanism for remote notifications;
* Tweak: Updated the texts and banners to look better on the replacement screen;
* Fix: Added documentation in the readme to disable the background removal feature (kudos to @jstask82);
* Fix: Increased the security of the plugin by adding checks for various AJAX calls;


Release date: February 21, 2023
* Fix: background removal notification is no longer displayed when this feature is disabled with the filter;
* Compat: improved compatibility with PHP 8.1 and 8.2
* Tweak: updated the banners on the replace page.


Release date: January 13, 2023
* Fix: patched a security vulnerability that could allow loading an unauthorized file during the replace operation;
* Fix: finish the replace operation even if the tmp file cannot be removed due to file permissions issues;
* Fix: when replacing a scaled file with a non-scaled file, some links were broken;
* Fix: under certain conditions a PHP warning about an undefined array key was displayed.


Release date: November 23, 2022
* Fix: files are now replaced correctly in environments running on Windows/IIC servers;
* Fix: the mime type is now correctly detected, so that a warning is no longer displayed when replacing PDFs;
* Fix: the plugin no longer tries to load its code for post IDs that are not attachments, like comments;
* Fix: some warnings were displayed when using the Members plugin;
* Compat: added integration for SiteOrigin Page Builder to correctly replace files in its widgets;
* Compat: added emr_after_remove_current action hook (thanks @luistar15);
* Tweak: added filter to disable the background replace functionality.


Release date: September 5th, 2022
* New: added the functionality to remove the background for any image;
* Fix: images added to the new block-style widgets were not replaced;
* Fix: the original file was not removed after replacement if a multilingual plugin was installed;
* Fix: additional checks were added to the new upload path for replacements, to avoid possible vulnerabilities, kudos to @soulseekah;
* Fix: an object cache flush was added after an image was replaced to prevent the content from still being cached in the post editor;
* Fix: if there was no _wp_attached_file in the postmeta table a fatal error was thrown;
* Fix: the time zone was not displayed correctly on the Replace Media screen;
* Fix: added some additional checks for file path to avoid open_basedir restrictions;
* Fix: added titles for the Replace Media and Remove Background screens;
* Fix: various small CSS/JS fixes, wording updates and code cleanups;


Release date: November 25th, 2021
* Fix: the shortcode file-modified works again for non-privileged visitors as well;
* Compat: if other plugins don’t properly use WP Hooks, don’t return errors;
* Tweak: updated banners list from the EMR screen.


Release date: November 8th, 2021
* Fix: there was an issue in file.php with checking mime-type, resulting in weird mime-type values in certain cases (thanks @dougaxe1 for the PR);
* Fix: if target mime type returns empty, don’t store that;
* Tweak: removed old notification about SPIO.


Release date: October 27th, 2021
* Fix: there was a broken image in one of the plugin notices;
* Fix: added a check for the function mime_content_type, which doesn’t seem to always be available on various hosts;
* Fix: the plugin checks if the current user has rights to install/activate plugins and only then displays the 1-click installers and also a filter is available now;


Release date: October 11th, 2021
* New: Constant EMR_CAPABILITY can define extra user roles to allow and deny replacements;
* New: Replacing an usual image with an SVG file will just replace all thumbnails by the main file;
* New: Also replaces caption when set in Exif data (when replacing with updating all links);
* Tweak: Added Now and Original options to Custom Date for usability;
* Tweak: changes/updates to the banners from the EMR screen;
* Fix: EMR now respects edit_other_posts permissions using default permissions;
* Fix: EMR with ALLOW_UNFILTERED_UPLOADS enabled (and allowed role) will not limit non-allowed uploads;
* Fix: some missing and wrong text-domains are now corrected (thanks @alexclassroom);
* Fix: a missing dot in the plugin description was preventing the transaltions to properly work;
* Fix: the plugin can now be uninstalled/deleted on PHP 8.


Release date: October 29th 2020
* New: EMR now replaces across all meta tables;
* New: the plugin remembers last used settings;
* New: integration with the LiteSpeed cache plugin and webserver;
* Tweak: manual Logging will no longer work if user is not logged as administrator;
* Tweak: added post_id to enable-media-replace-upload-done action args, props to @Jan Stiegler;
* Fix: fully works now with Elementor;
* Fix: the issue for WP-Bakery and URL-Encoded links is now fixed;
* Fix: the plugin should now work with images added through Visual Composer;
* Fix: EMR now uses queries instead of WordPress functions, correctly handling slashes and JSON formats;
* Fix: -scaled images generated by WordPress are now removed when replacing an image;


Release date: August 17th 2020
* New – Also display files size in the replacement windows;
* Fix – Replacing image with pdf file would cause noticesi;
* Fix – Compensation for faulty WordPress installation that return empty error string on wp_upload_dir and falsely return relative paths and urls on WP core functions;
* Fix – When choosing ’replace file and update names’ and then uploading a file with identical name as source, it would postfix the duplicate name. This is no longer the case;
* Fix – Wording clarification for the situation when the filename is changed, which will lead to broken links from external sites;
* Fix – Added hard paths to require_once satements in order to prevent WP-CLI errrors;
* Fix – If source image doesn’t exist or in error state, replacement would be prevented by Javascript issue.


Release date: June 18th 2020
* Fix – PHP Error when settings permissions failed.


Release date: June 9th 2020
* New – In edit media screen EMR notes user who replaced file if this was not uploader;
* New – Added Drag and Drop area for files;
* New – When replacing with new file name, now also possible to update upload path;
* Fix – Various minor CSS tweaks and fixes;
* Update of Underlying libraries


Release date: 27th April 2020
* Fixed – When trying to upload over-limit file would show too many error messages;
* Language – 2 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted.


Release date: 10th March 2020
* Fix the crashing of certain frontend builders when the plugin is active.


Release date: 23rd February 2020
* Fix issue with JSON encoding which was interfering with Advanced Custom Fields and other plugins


Release date: 23rd February 2020
* Fix issue with JSON encoded strings
* Language – 0 new strings added, 2 updated, 0 fuzzied, and 0 obsoleted

Release date: 19th February 2020
* Fix issue with search/replacing non-image attachments and query
* Language – 0 new strings added, 2 updated, 0 fuzzied, and 0 obsoleted


Release date: 18th February 2020
* Fixes for WP 5.3+ -scaled images system. Will now replace those as well.
* Updating and replacing images and thumbnails should now work for serialized (and such) metadata.
– For Beaver Builder
* Add extra warning if mimetype is not allowed by WordPress for upload
* Put Javascript version in wp_register_script
* Hidden double ’replace media’
* Replace Image label to Replace Media
* Removed constant S3_UPLOADS_AUTOENABLE
* Improved detection of SVG image sizes
* Fixed – Logger doesn’t call wp_upload_dir when not debugging
* Extra – Javascript tries to resume after external errors.
* Language – 0 new strings added, 2 updated, 0 fuzzied, and 0 obsoleted


Release date: 13th November 2019
* call the hook enable-media-replace-upload-done on both modes
* fix JSON compatibility for hostings that don’t have JSON module activated
* Language – 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted


Release date: 5th September 2019
* fix JSON compatibility for hostings that don’t have JSON module activated


Release date: 25th July 2019
* fix Replace button on the MediaLibrary image details popup


Release date: 23rd July 2019
* compatibility fixes for WP version 4.8 and below
* cache killer


Release date: 19th July 2019
* Fix error ”using $this when not in object context” on some PHP versions


Release date: 17th July 2019
* Check if medium size !> 400px, display that one, otherwise smallest.
* Fixed: Links not updated when using Advanced Custom Fields
* Fixed: Fails silently when file is too big for upload
* When source file does not exist, show placeholder instead of failed image load
* Fixed: Fatal error when replacing images
* Fixed: Not the right time zone on replace
* Fixed Beaver Builder incompatibility by not allowing replace with rename.
* Fixed: Cannot replace non default WordPress file types, even those allowed to upload [ Media Library Assistant compat ]
* Fixed: error when trying to remove a file that doesn’t exist – because the files are actually on another server


Release date: 18th June 2019
* Fix error class not found on WPEngine


  • When replacing an image and changing the name, Search / Replace is now also done on the meta_value of postmeta.
  • Replace PDF thumbnails too
  • Copy title from EXIF
  • RTL View incorporated into the CSS
  • ‘wp_handle_upload’ filter should be treated as such (and not as action)
  • Use wp_attached_file instead of the GUID
  • Fix: replace missing file
  • Fix: aphostrophe breaking the upload
  • Fix: broken ”before” image
  • Fix: update properly the date
  • Fix: errors for non-image items in Media Library
  • Fix: empty admin menu item created
  • Refactored all the code


  • properly replace thumbnails names in the content when the replaced image has a different aspect ratio, thus the new thumbnails have a different height in the name.


  • fix for failures in link updating when replacing file because of addslashes – use prepared query instead
  • replace basename with wp_basename because basename doesn’t work well with UTF8


  • Add minimum required php version to run the plugin.
  • Security: Prevent direct access to php files.
  • Security: Prevent direct access to directories.
  • Security: Escape translation strings using esc_attr__() and esc_html__() functions.
  • Fix RTL issues.


  • no more 404 error if no image was selected when trying to replace it
  • added preview so you can check the image being replaced and also the image that’s being replaced with
  • .dat files can be replaced (functionality accidentally removed in the previous version)
  • added compatibility with S3 upload plugin
  • when an image is replaced the date is also updated


  • remove the leftover setcookie and the plugins recommendations.


  • Fix PDF thumbnails not replaced when replacing a PDF
  • Fix not replacing text files with .dat extension


  • disable ShortPixel recommendation on secondary sites of a multisite install when it was network activated.


  • Fixed compatibility with ShortPixel and Resize Image After Upload
  • Added ShortPixel links and images, fixed the problem of ShortPixel recommendation not dismissing.


  • Bugfix, typo made metadata changes (thanks GitHub user icecandy!)
  • Removed Shortpixel links and images


  • Tested with WP 4.9.4
  • Added Shortpixel link in replace media screen


  • Fixed bug introduced in an earlier version, preventing the updating of URLs on pages/posts if the link did not contain the domain name


  • Got rid of some pesky old code, and added some better filtering options, thanks to GitHub users speerface, aaemnnosttv, and ururk
  • Helt ny, glänsande kod för att ersätta andra bildstorlekar i inbäddade medier, tack till GitHub-användaren ianmjones!
  • Testad med WP 4.8


  • Testad med WP 4.7.2
  • Ny PT-översättning (tack Pedro Mendonca! https://github.com/mansj/enable-media-replace/commit/b6e63b9a8a3ae46b3a6664bd5bbf19b2beaf9d3f)


  • Testad med WP 4.6.1


  • Fixed typo in .pt translations (https://github.com/mansj/enable-media-replace/pull/18)
  • Fixed better error handling in modification date functions (https://github.com/mansj/enable-media-replace/pull/16)
  • Testad med WP 4.4.1


  • Scrapped old method of detecting media screen, button to replace media will now show up in more places, yay!
  • Made sure the call to get_attached_file() no longer skips filters, in response to several users wishes.
  • Suppressed error messages on chmod()
  • Lagt till japansk översättning (tack, chacomv!)


  • Rensat upp språkfiler
  • Lagt till portugisisk översättning (tack pedro-mendonca!)
  • Testad med WP 4.1
  • Lagt till saknade svenska översättningssträngar


  • Tiny fix to re-insert the EMR link in the media list view.


  • Uppdaterad för WordPress 4.0
  • Now inheriting permissions of the replaced files, Thank you Fiwad



  • Added fix by Grant K Norwood to address a possible security problem in SQL statements. Thanks Grant!
  • Created GitHub repo for this plugin, please feel free to contribute at github.com/mansj/enable-media-replace


  • Bug fix for the short code displaying the modification date of a file
  • Uppdaterade alla databasfrågor för att förbereda WP 3.9


  • Buggfix för tidszonsändringar i WordPress
  • Minor UI change to inform the user about what actually happens when replacing an image and using a new file name


  • Added call to update_attached_file() which should purge changed files for various CDN and cache plugs. Thanks Dylan Barlett for the suggestion! (https://wordpress.org/support/topic/compatibility-with-w3-total-cache)
  • Suppressed possible error in new hook added in 2.9.2


  • Små buggfixar
  • Added hook for developers to enable purging possible CDN when updating files – thanks rubious for the suggestion!


  • Lagt till brasiliansk portugisisk översättning, tack Roger Nobrega!
  • Added filter hook for file name creation, thanks to Jonas Lundman for the code!
  • Added modification date to the edit attachment screen, thanks to Jonas Lundman for the code!
  • Enhanced the deletion method for old file/image thumbnails to never give unnecessary error messages and more accurately delete orphaned thumbs


  • Lagt till portugisisk översättning, tack Bruno Miguel Bras Silva!
  • Ny redigeringslänk från mediebiblioteket
  • After uploading, the plugin now takes you back to edit screen instead of library


  • Made another change to the discovery of media context which will hopefully fix a bug in certain cases. Thanks to ”Joolee” at the WordPress.org forums!
  • Added a new, supposedly better Russian translation from ”Vlad”.


  • Fixed a small bug which could create error messages on some systems when deleting old image files.


  • New and safer method for deleting thumbnails when a new image file is uploaded.
  • Nya översättningar för förenklad kinesiska (tack Tunghsiao Liu) och italienska (grazie Marco Chiesi)
  • Added method for detecting upload screen to ensure backward compatibility with versions pre 3.5


  • Ett par ändringar gjorda för att säkerställa kompatibilitet med WordPress 3.5. Tack till Elizabeth Powell för fixarna!


  • New and improved validation of uploaded files, now using WP’s own functions for checking file type and extension. Thanks again to my old friend Ulf ”Årsta” Härnhammar for keeping us all on our toes! 🙂 This should also hopefully fix the problems people have been having with their installations claiming that perfectly good PDF files are not allowed file types.


  • The ”more reliable way” of determining MIME types turned out to be less reliable. Go figure. There seems to be no perfect way of performing a reliable check for MIME-types on an uploaded file that is also truly portable. I have now made checks for the availability of mime_content_type() before using it, using the old method as a fall-back. It is far from beautiful, so if anybody has a better way of doing it, please contact me!


  • Bug fix – there is now a more reliable way of determining file type on your upload so you can upload PDF files without seeing that pesky ”File type does not meet security guidelines” message.
  • Ny översättning till danska – tack till Michael Bering Petersen!


  • Testad med WordPress 3.2.1
  • Ny översättning till tyska – tack till Martin Lettner!
  • New translation to French – thanks to François Collette!


  • Buggfix för WordPress 3.1 RC. Nu ordentligt testad och ska fungera med 3.1 när det nu kommer ut. 🙂


  • Bug fixes, security fixes. Thanks to my old pal Ulf ”Årsta” Härnhammar for pointing them out!
  • New method for uploading avoids going around WP, for greater security.


  • Lots of code trimmed and enhanced, thanks to Ben ter Stal! Now working properly with Windows systems, better security, optimized loading, and much more.
  • Lagt till nederländsk översättning av Ben ter Stal.


  • Bug fix, fixed typo in popup.php, thanks to Bill Dennen and others for pointing this out!


  • New shortcode – display file modification date on your site (see description for more info)
  • A couple of bug fixes for final release of 3.0 – Thanks to Jim Isaacs for pointing them out!


  • Lagt till stöd för SSL admin


  • Replaced popup with inline navigation when replacing media
  • Added instructions in admin link under Media


  • Testad med WordPress 3.0 beta 2


  • Removed short tags for better compatibility.


  • Added support for wp_config setting ”FORCE_SSL_ADMIN”


  • Lagt till rysk översättning, tack till Fat Cower.


  • Mindre buggfix, nu fungerar det med IE8 också!


  • Första stabila versionen av tillägget.