0

Just started noticing this recently, I don't think it was an issue before but can't see what would have changed to cause this. We have General Link field for one of our templates and when I click the Insert Media Link in it and find the media item I want to link to, it inserts the correct path but leaves out the initial /~/media and so when that item is published, we get a 404 when clicking on that link.

If I manually add /~/media at the beginning of that inserted path, however, the link resolves fine.

Can anyone give me a hint as to why either the /~/media isn't being inserted when clicking on this button, or why the path without that prefix wouldn't be resolving (if indeed it should be able to)?

Just looked at my configs and the medialink prefix is set to "" and there's a customhandler:

<handler trigger="~media/" handler="sitecore_media.ashx">

As far as I can tell, this should all be working fine, but I still don't get this prefix added to paths when clicking the Insert Media Link button for the content item...

0

You should set your media link prefix to ~/media, as follows:

<setting name="Media.MediaLinkPrefix">
        <patch:attribute name="value">~/media</patch:attribute>
</setting>

Also, your handler trigger value should be: ~/media/

Note: it is recommended to use hyphen - prefix due to performance issues https://kb.sitecore.net/articles/723979

| improve this answer | |
  • Ok, but will this break the links that are already being specified with the tilde? Will I need to change all of these? – Levi Wallach Apr 29 '17 at 13:34
  • I've added in a patch file as you are suggesting, and confirm that it is set to "~/media". I also have a handler trigger set to "~/media/" (my statement above was a typo). I even added an additional handler trigger for "-/media". None of this changes what gets inserted when I click on the insert media link button. It includes the path after the Media Library node, but nothing prior to that. If I click on insert link, it prefixes "/sitecore/media library" to the path. In either case actually clicking on the link on the published page yields a 404. – Levi Wallach May 2 '17 at 13:00
  • I'm not sure what version @LeviWallach is using, but it looks like this might have been fixed in Sitecore 8.1, per the linked KB article. – James Skemp May 2 '17 at 20:44
0

It turned out that it had nothing to do with the medialinkprefix setting, which was fine. Rather it turned out to be an issue with how the url was being generated on the delivery end. This particular sublayout apparently had never been used to link to media files, only to internal or external urls, and so the code behind did not account for media item links, which are different. I ended up using some of the code specified in this helpful post: https://briancaos.wordpress.com/2012/08/24/sitecore-links-with-linkmanager-and-mediamanager/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.