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!
Supported by the friendly team that created ShortPixel 🙂

A real timesaver

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

Well, no longer!

Now you’ll be able to replace any uploaded file from the media ”edit” view, where it should be. Media replacement can be done in one of two ways:

Det är enkelt att ersätta en fil

  1. Just replace the file. This option requires you to upload a file of the same type as the one you are replacing. The name of the attachment will stay the same no matter what the file you upload is called.
  2. Replace the file, use new file name and update all links. If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file will be updated to point to the new file name.

This plugin is very powerful and a must-have for any larger sites built with WordPress. It now also comes with preview of the replaced image!

Display file modification time

There is a shortcode available which picks up the file modification date and displays it in a post or 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 display 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 used to display the time, you can use the format option, so [file_modified id=870 format=Y-m-d] would display the file modification date but not the time. The format string uses standard PHP date() formatting tags.

Compatible and recommended Plugins =

  • ShortPixel Image Optimization – Enable Media Replace is fully compatible with this plugin. Once enabled, ShortPixel will automatically optimize the images you replace using Enable Media Replace.
  • Resize Image After Upload plugin – automatically resize images upon upload to save traffic & disk space. Good for SEO and compatible with EMR.
  • Regenerate Thumbnails Advanced – Fast, free and simple to use plugin to regenerate the thumbnails for your site after changing a theme (for example). Supported & maintained by ShortPixel

Wishlist / Coming attractions

Do you have suggestions? Feel free to contact ShortPixel here


  • Den nya länken i mediebiblioteket.
  • The replace media-button as seen in the "Edit media" view.
  • Uppladdningsalternativen.
  • Get the file ID in the edit file URL


Snabb och enkel installation:

  1. Upload the folder enable-media-replace to your plugin directory
  2. Aktivera tillägget via menyn ”Tillägg” i WordPress.
  3. Klart!

Vanliga frågor


Snabb och enkel installation:

  1. Upload the folder enable-media-replace to your plugin directory
  2. Aktivera tillägget via menyn ”Tillägg” i WordPress.
  3. Klart!
Vad gör det här tillägget egentligen?

This plugin makes it easy to update/replace files that have been uploaded to the WordPress Media Library.

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.

I replaced a file, but it didn’t change!

There are two main reasons this would happen.

First, make sure you are not viewing a cached version of the file, especially if you replaced an image. Press ”Refresh” in your browser to make sure.

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.


very good!

it does exactly what it should, works well, is easy to use and takes away all the headaches when you have to replace the same images again and again!

True plugin

Excellent! This plugin give a chance correct replace image without SQL database edit.

A real time saver, plus excellent support!

Each week I have to change between 25 and 30 images, this plugin makes the job incredibly easy and fast. When I did have a problem and asked for help, the response was very fast and fixed the problem on the first try.

More trouble than it was worth

Replaced images didn’t show up properly. I deactivated the plugin, and images stopped showing on my pages, posts, and in my media library.

In half the time it took me to research and implement a fix, I could have replaced the images manually.

Works as expected

This plugin does what it says.
The 2 different options are very useful :
– only replace the file and keep the same name
– replace the file by a new file with a different name AND update all links to point to this new file

Perfect time saver

Läs alla 178 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 21 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.



  • 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!
  • Lagt till en ny, förmodligen bättre rysk översättning från ”Vlad”.


  • Fixat en liten bugg som kan skapa felmeddelanden på vissa system när du tar bort gamla bildfiler.


  • Ny och säkrare metod för att radera miniatyrbilder när en ny bildfil laddas upp.
  • 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!
  • Ny översättning till franska – tack till 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.