Replace an existing document

When a policy, form or guide is revised, replace the file that is already in the Media Library instead of uploading a new one. The web address of the file stays the same, so every link to it, every Document attachments list and every bookmark keeps working, and the old version is gone. This works for images as well as documents.

WordPress on its own cannot do this. Uploading a file with the same name simply saves a second copy with “-1” added to its name, and the old file stays where it was. Replacing needs the Enable Media Replace plugin, which is on the list of optional plugins in Install plugins. Look for Replace media in the Media Library to see whether your intranet has it.

Find the file and open Replace media

  1. Go to Media, then Library. Switch to the list view, the button with horizontal lines at the top left, and search for the file.
  2. Hover over the file name and select Replace media from the links that appear under it.

If you already have the file open, the same thing is available as Upload a new file in the Replace Media box on the right of the edit screen, or in the Replace media field of the Attachment details pop-up in the grid view.

Choose the replacement file and how to replace it

The Replace Media Upload screen shows the file you are about to replace and warns that there is no undo. Keep a copy of the old version if you might need it.

  1. Under Select Replacement Media, select the box to choose the new file, or drag the file onto the page from your desktop. The file must be within the intranet’s maximum upload size, which is shown on the screen.
  2. Under Replacement Options, choose one:
    • Just replace the file. This is the default and the right choice almost every time. The new file must be the same type as the old one, PDF for PDF, and it takes the old file’s name and address, so nothing else changes.
    • Replace the file, use the new file name, and update all links. Choose this only when the file type or name must change, for example a Word file becoming a PDF. The plugin edits the links in your content to point at the new name. Links from outside the intranet, or in emails staff have saved, will break.
  3. Under Options, choose what to do with the file’s date: Keep the date is the default and keeps the file where it was in the Media Library, sorted by its original upload date. Replace the date with the current date moves it to the top, which is useful if the library is sorted by date. Set a Custom Date lets you type one.
  4. Select Upload. A “File successfully replaced” message confirms it.

Update the title and check the page

Replacing the file does not change its title, caption or description in the Media Library. If the title includes a version or a year, open the file and update it, because the title is what appears in Document attachments lists and is what the Media A to Z and search show. Then open a page that links to the document and follow the link to make sure the new version downloads.

Document attachments lists and the file type icons and sizes beside document links are read from the current file, so they update by themselves.

If the old version still appears

  • Browser cache. The person’s browser has kept the old file. Ask them to reload the page with Ctrl + F5 (Command + Shift + R on a Mac) or open the link in a private window.
  • Page cache. If the intranet uses a caching plugin such as WP Super Cache, an administrator may need to clear the cache.
  • Replaced images look wrong. WordPress makes several sizes of each image when it is uploaded. Replacing an image with one of different dimensions can leave old cropped sizes in use until they are regenerated. Replace images with ones of the same size and shape where you can.

Without the plugin

If your intranet does not have Enable Media Replace, upload the new version as a new file with Add Media, then update every link to it. To find them, search the intranet for the document’s title, and check any page that lists it in a Document attachments box: remove the old file from the box and add the new one. When every link is updated, delete the old file from the Media Library so that search does not offer it. See Add links to pages including documents and email address links.