Finding and updating media

If you use the "approved method" outlined here, Umbraco will maintain all links to your media for you.

With a little tweak to your file naming habits you can also maintain permanent links for your external users.

Updating "files"

It is common practice among editors to upload file revisions as new media items and re-link the page to the new media. This is both dangerous and wasteful because:

  • The old file is often linked from more than one place and unless you check carefully you may leave other pages linked to this old file [dangerous].
  • Even if you check carefully you will need to visit every page and update the link to the new file [wasteful].
  • Once you have updated the pages to point to the new link, unless you delete the old file carefully [wasteful] it will be left available on the web [dangerous].

Step 1 finding the thing

Umbraco allows you to "organise" your files into folders which is good but it does make it easy to lose track of the file. Unfortunately, Umbraco does not make it easy to locate media from the page or editor; the media link is of the form /media/nnnnn/name.ext which does not describe the location in Umbraco and the number is not the media item's ID so you can't search for it based on that.

the media link

You can see from the above that the first link on the page above is

You may be able to find the media using the media search and one or more of the keywords suggested by the file name which worked for this file but won't always.

media search results

The most reliable way to find a media item is by using its media ID. Fortunately our Umbraco system adds the media ID to the underlying code of every file link and it is only a right click away. To open the code for the link, right click it and look for the "inspect" option on the pop-up menu.

inspect pop up

You will see the code inspector (they differ slightly between browsers) with the code for the link selected.

media inspect panel

The highlighted item in the image above is the "data-id" attribute which contains the Umbraco media ID. Use this in the search and you get only the file you are looking for.

media id search

Step 2 updating the media item

The file tab has a "Choose file" button you use to find the updated version which will queue it for updating.

update queued

Hit save & you'll see a message about saving successfully and others for each page where Umbraco has updated the link.

update successful

Your file is now updated, as is the link to it on every page that uses it.

You will have to check the link text in case you have used any "perishable" phrases such as "updated December 2014" which no longer apply.

You can trace and edit each page the file is linked from through the "Content usage" tab.

content usage

You can open an editor to each page by holding the [Ctrl] button and clicking the last link in the crumb trail (as highlighted above).

Creating "permalinks" for media files

As you may have noticed above, when you upload a file, its filename is used in the media link. This means that many of our common methods of naming files result in the underlying media link changing, eg:

  • Old file: MyFile-Dec-2016.doc
  • New file: MyFile-updated-Jan-2017.docx

…would result in a link change because we:

  1. injected an "updated" in the name
  2. changed the date
  3. saved it as a new docx type

Any one of the changes would change the link.

If you need to create links that always stay the same you can see that you need to keep the file name the same (and if you have to, change the link text on your pages to update the "perishable" text).

Although recommended, it is unnecessary to give all the dates and versions in the file name - this should be in the document metadata block

It does make file management a little more complicated as you can't spot versions from the file manager. It's therefore only advisable if you have to create a permalinked document.

Help us improve Gloucestershire County Council

Don’t include personal or financial information like your National Insurance number or credit card details.