Skip to content

How to Replace Images or Media Files on a WordPress

If you find yourself working with a lot of images or other media files in WordPress, chances are good that at some point you’ll need to change a file’s content while still keeping links and image placement the same. The best way we’ve found to do this is with a free plugin called “Enable Media Replace”. In this Quick Guide, we’ll teach you how to install this plugin and use it to replace images that already exists or media files on your WordPress site.

There are a number of different things that could cause you to need to replace images in your media library. Like:

  • Your team linked a media file in a marketing campaign, and you don’t want your flyers with the old URL to break
  • You used some of the files in your WordPress media library and in your themes or plugins and you can’t go alter the instances of those in the code easily
  • Your logo changed, and you just want to make sure that change is reflected everywhere.

Here’s the video explaining how you can change an item in your WordPress media library:

How to Replace Images Without a New Name & Location

  1. From your dashboard, select “Plugins”>”Add New”.
  2. Search for “Enable Media Replace” in the “Add Plugins” search box.(click to enlarge)
  3. When you find the listing for “Enable Media Replace” by Måns Jonasson click “Install Now”.
  4. Click “Activate Plugin”.
    (click to enlarge)
    (click to enlarge)
  5. Open up the file you wish to replace by selecting “Media”>”Library” from the left dashboard menu.
    (click to enlarge)
    (click to enlarge)
  6. Click on the image or other media item you wish to change.
  7. From the page titled “Attachment Details”, scroll down until you find the section on the right side titled “Replace Media”.
  8. Hit the “Upload a New File” button.
    Replacing an image in WordPress
    (click to enlarge)
  9. Click the button titled “choose file” and select the new file you wish to replace your current one.
  10. Choose the appropriate setting for your situation. If you’re uploading a file of the same type as the one you’re replacing, keep the default setting “Just replace the file” selected.
  11. Click “Upload”.
    (click to enlarge)
  12. That’s it! Double check that it appears the way you want it to on yours site, and that a confirmation message appears from WordPress above your new file.
    (click to enlarge)
    (click to enlarge)

Replacing WordPress Images: A Note on Caching

If you’ve replaced an image but you’re still seeing the old one, the most likely issue is caching.

If you’ve replaced an image but you’re still seeing the old one, the most likely issue is caching: even though the new image did upload properly, your system has saved a version of the old image, and that’s what it’s giving you.

There are lots of types of caching, but the most common issues here would be:

  1. A hosting-based caching solution, like SiteGround’s SuperCacher or WP Engine’s cache. Clear this using whatever method the host makes available.
  2. A cache plugin like WP Super Cache. Clear this using whatever method the plugin makes available.
  3. Browser-based caching: your browser, like Chrome or Firefox, saving old copies of media files. Hard-refresh the page where the image appears with ctrl+shift+r (PC) or cmd+shift+r (Mac).

If you’re getting stuck in caching layers after replacing an image, give those a try!

Yay! 🎉 You made it to the end of the article!
David Hayes
Share:

12 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Iain Ward-Campbell
November 26, 2021 12:14 pm

I have deleted a document from the media library and replaced it with an amended version with the same file name…..it is a pdf. All my links to the document continue to display the old one even though it has been ‘permanently’ deleted from the library, and the changed file has been successfully uploaded. What can I do without installing yet another plug-in?

clarence bowman
February 28, 2021 1:25 pm

there is also a plugin called WXY Tools Media Replace that is easier to use and works anywhere you can upload an attachment. It also preserves any alternate text, descriptions, or categories for attachments. Hope this is helpful.

daniel lert
November 27, 2019 1:04 pm

How can I do this with multiple images ?
I want to replace hundreds of files at once.

Bec
March 22, 2020 1:51 am
Reply to  daniel lert

I’m in the same boat. Did you find a solution?

Brian
August 5, 2018 5:59 pm

Doesn’t seem to do anything, cache was cleared . . . back to renaming files when they need to be updated, at least it is consistent.

Dieter
July 29, 2018 6:29 am

I loved this plug-in, but it stopped working recently

Rukhsar
June 2, 2018 1:33 am

is it necessary that same image size will b replaced others are not?

Cecilia
February 11, 2018 9:05 pm

Before I read this article, I deleted the old file and tried to re-upload a new one with the same file name. I found it doesn’t work and then I download mentioned plugin and re-do the steps. Actually, I want to replace a pdf file. What can I do?

P.S. I tried to use different browsers to check if I succeed and even delete cache
Thanks for your help.

Ian Malik
August 13, 2017 1:14 am

After spending hours trying to figure out how to replace an image, your solution was simple, effective and very much appreciated….. THANK YOU!!

SUBRATA SARKAR
March 5, 2017 10:37 pm

Followed all steps as described above but no image is getting replaced! What could be the reason?

1. Do I need to make sure the dimension of my new image file exactly matches the old one?

2. Do I need to make sure the file extension of new image file must be the same
as of the old one?

3. I don’t see any permission issue as old images got uploaded from CPT forms in front end.

4. I am using a independent custom theme built from scratch. There is no parent theme associated. I am almost certain this cannot be an issue but just mentioning in case there is any relation.

5. OS: Ubuntu 14.04 LTS. WordPress version: 4.7.2

Am I missing something?!

Fred Meyer
March 6, 2017 12:46 pm
Reply to  SUBRATA SARKAR

Hi Subrata,

My best guess would be caching: You’re still seeing a cached version of the image rather than the new image.

What hosting are you on, and do you have any caching plugins running?

Fred

WordPress: Medien-Dateien ersetzen » perun.net
July 22, 2016 10:43 am

[…] via WPShout […]

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!