improvement · module

How to get public URL of a media item inside Sitecore

This one is to introduce an approach for getting public URL of a Sitecore media item inside Sitecore. As you all know in large setups the CM and CD are separated so it’s not always easy to know or guess what the public domain is especially for multisite setups. With user friendly public url, the user can copy the link and share it around easily.


  • creating a new Sitecore field Media Public Url Picker which has a link menu Get Public Url
  • clicking on Get Public Url link, a pop-up is displayed with a textbox contains the public URL which is generated automatically
  • modifying any Sitecore media base templates to add new Media Public Url Picker field (Ex: /sitecore/templates/System/Media/Unversioned/Image)
  • modifying Sitecore media folder template (/sitecore/templates/System/Media/Media folder) to add a new field contains the domain portion, for instance:
    • field name: PublicDomain
    • field type: Single-line Text
  • if the domain portion is NOT available in any recursive media folders of a media item, it will be fetched from the config file as default public domain

If that is the case, you may want to play with my Media Public Url Picker field.

How to install it

Download this one as a Sitecore package on Sitecore Marketplace or on Gitlab then install it to your Sitecore instance via Installation Wizard.

How to use it

  1. log into Sitecore, upload a media
    • mpup_1
  2. open the new media item, click on the template link
    • mpup_2.png
  3. you’re now in the template editor:
    • select Builder tab
    • add new field section Media
    • add new field Public URL whose field type is Media Public Url Picker and set it as shared field as well
    • click Save button (or Ctrl+S)
    • mpup_3.png
  4. back to that media item editor, you would see the new field Public URL has a link menu Get Public Url then click on that link, a pop-up with public URL should be displayed
    • mpup_4.png
  5. looks OK now, let’s try to replace the domain portion to your own one
    • open \App_Config\Include\z.Vhs.MediaPublicUrlPickerField.config
    • modify this one
    • mpup_5

Note: please repeat #2 and #3 for each media base templates such as Image, Audio, Document, File inside “/sitecore/templates/System/Media/Unversioned” and “/sitecore/templates/System/Media/Versioned” if necessary

Is there a way to specify the domain portion for a specific media folder so that this module is able to support multisite implementation?

Yes, there is (at least in my opinion). Please follow these steps below to set it up:

  1. log into Sitecore, open a media folder item and click on the template link
    • mpup_6
  2. you’re now in the template editor:
    • select Builder tab
    • add new field section Media
    • add new field PublicDomain whose field type is Single-Line Text and set it as shared field as well
    • click Save button (or Ctrl+S)
    • mpup_7
  3. open \App_Config\Include\z.Vhs.MediaPublicUrlPickerField.config
    • add PublicDomain to this setting (Note: | is separator so that it’s able to play with multiple field name)
    • mpup_10
  4. edit any media folder item, you would see a new field PublicDomain and you’re able to enter a new domain
    • mpup_8
  5. open a child item of that media folder item, click one Get Public Url link to see a new public URL
    • mpup_9.png

Note: the logic is to manage to find out the domain portion in the nearest ancestor items if possible. If nothing is available, will use the default public domain in the config file.

Integration examples:


Not Good Enough? Please feel free to download the source code and add your own enhancements if necessary.

Got issues?

Please send your issues (with screenshots if possible) to so that I have a chance to understand your problem and be able to suggest the solution.

Happy Sitecore coding!


2 thoughts on “How to get public URL of a media item inside Sitecore

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.