mtelligent

View Original

How to Figure out the Url of an Item in Sitecore's Media Library

Sitecore makes it easy to link to images or assets in the media library using link or image fields or in the Rich text editor. But sometimes you just need to get a url for an image without having to use it as content for a page. Unfortunetly most articles that you get when you try googling how to get the url are focused on programmatic solutions.

When you need a link to a published item in the media library, there are two easy ways to create a url to it.

https://HostName/-/media/(Item ID without Brackets or Dashes)
https://HostName/-/media/(Path to Item after /Sitecore/Media Library)

While the later approach gives a much friendlier url, the Benefit of the former approach is that link will work regardless of where the image is in the content tree, so you won’t need to worry in case the media library gets reorganized with a new folder structure.

Hopefully this helps someone who is looking for a non programmatic approach to getting media library image or file urls.