I'm new to Umbraco and using version 7. I'm having a problem with links to media files (pdf) breaking when a revised document is added to a media item. So when version 2 of a doc comes along I don't want to repost to all the pages referencing it I just want to update the media item and all links get the new file.
I would have thought this was fairly standard stuff within any CMS but my Developer tells me that default behaviour within Umbraco 7 is that the link breaks and you have to edit all links pointing to that file. This leaves me no further on than editing the website manually.
Can anyone confirm if this is a bug or just how Umbraco works..??
That sounds unusual. If you are referencing a media item by it's ID then you should be able to retrieve the current Url of the media item, regardless of whether the physical file name has changed or not:
Thanks Dan - I'm going to forward that to the Dev that developed the templates we are using to get his take on it but that makes more sense to me than using the physical path to the document that has been upload "/media/2956/23c3956a-1b73-495a-b95f-3c7fe707cd90.pdf". Can the WYSIWYG editor be made to use the value above rather than the physical path?
Stephen - I just created an item in the Media Library and once the file had uploaded successfully I linked to it via the WYSIWYG editor and it used the path above. Then as a test I updated the file associated with the Media Item to see if it updated the link in the page and I just got a 404.
I'm NHS so the sites we develop are very document heavy with Policies, Guidelines, SOPs etc that are often revised so I need to make this very easy for content owners to be able post a revised document without the need to trawl the site and edit all links that reference the document.
In a Razor script. For the Marco you will need to create a Parameter called mediaId which is a media "Single Media Picker", and ensure that "Use in rich text editor" is ticked.
Then in teh rich text editor just insert this macro type and use the picker to pick the file. The name displayed in the URL is pulled from the name given to the file in the media section. The only downside I can see is I am 99% sure this is wrapped in a div, so can't be part of a sentence. But I think it work with file updates, so long as the media ID is unchanged, I haven't got time to test that bit.
With some fairly simple changes it could be turned in to a multiple media picker. Please not I have been fairly lazy and left out any error checking, so if no file is picked an error may be displayed, either that or an empty link.
A small amount of extra training required for users, but much lower maintenance if it works. Alternately you could hard code a related files section into the website, and use a multiple picker and some Razor code to create the extra section on the website.
Media Links in Umbraco 7
Hi
I'm new to Umbraco and using version 7. I'm having a problem with links to media files (pdf) breaking when a revised document is added to a media item. So when version 2 of a doc comes along I don't want to repost to all the pages referencing it I just want to update the media item and all links get the new file.
I would have thought this was fairly standard stuff within any CMS but my Developer tells me that default behaviour within Umbraco 7 is that the link breaks and you have to edit all links pointing to that file. This leaves me no further on than editing the website manually.
Can anyone confirm if this is a bug or just how Umbraco works..??
Thanks
Hi Michael,
That sounds unusual. If you are referencing a media item by it's ID then you should be able to retrieve the current Url of the media item, regardless of whether the physical file name has changed or not:
What property type are you using to select the media item? How are you rendering your media item on a template?
Thanks, Dan.
Hi Michael,
I take it this is actually happening for you, they are breaking, you haven't just been told they will break.
What process are you using to update the PDF?
And how have you linked to the PDF (what process have you used)?
Thanks
Stephen
Thanks Dan - I'm going to forward that to the Dev that developed the templates we are using to get his take on it but that makes more sense to me than using the physical path to the document that has been upload "/media/2956/23c3956a-1b73-495a-b95f-3c7fe707cd90.pdf". Can the WYSIWYG editor be made to use the value above rather than the physical path?
Stephen - I just created an item in the Media Library and once the file had uploaded successfully I linked to it via the WYSIWYG editor and it used the path above. Then as a test I updated the file associated with the Media Item to see if it updated the link in the page and I just got a 404.
I'm NHS so the sites we develop are very document heavy with Policies, Guidelines, SOPs etc that are often revised so I need to make this very easy for content owners to be able post a revised document without the need to trawl the site and edit all links that reference the document.
Thanks for the repsonse BTW
Cheers Michael
Hi Michael,
This is untested, but in theory this code should work:
@{
var media = Model.MediaById(Parameter.mediaId);
<a href="@media.umbracoFile" title="@media.name">@media.name</a>
}
Cheers Stephen
Forwarded to our Developer, I'll let you know how it goes
Cheers Michael
is working on a reply...