Many of our clients provide up to date information to guests on their website in a PDF file. This could be a cumbersome task to replace every link to that media file if it were hard coded that way, but instead, we can reference that PDF using Drupal's Media Library. Below are instructions for replacing a PDF with a new version and also how to link to a PDF so all links to that file get updated.
Video Instructions
Replacing a PDF with a New Version
To replace a PDF that has already been uploaded with a new version, use the instructions below.
- Go to Content > Media > Media Library
- Filter the media by document type if desired.
- Click the pencil icon on the PDF you wish to replace.
- Make sure "overwrite original file" is selected. It should already be selected by default.
- Then click "Save".
Linking to a PDF from multiple pages correctly
When adding a link to a PDF, use the Link tool instead of the Media Tool or also manually copying and pasting the URL from the Media Library.
- Select the text you want to add the link to. Use the Link Tool.
- Use the search Link URL for finding the PDF you want to link to. Be sure to include any dashes that are in the filename.
- From the search results, select the file you want to link to.
- The CMS will add the link to the Media item using a media ID. Be sure to click the green checkmark to accept!
- You can tell if the file is linked correctly by looking at the Source code. It will show data attributes for "data-entity" like below.
If you would like to add that same PDF to another page, make sure to reference the media ID of the document. Shown below is the link to "/media/209". You can use that same reference on other pages and they will all point to the same file.
Hint: You can go to the Media Library and verify it's the same file by looking at the media id in the URL.