I know “MediaLinkPrefix” can be changed in web.config. But is it possible to change “MediaLinkPrefix” Programmatically? Thanks!
I know MediaLinkPrefix can be changed in web.config. But is it possible to change
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To answer your specific question. No. You cannot programmatically change the value of that setting.
If you are trying to use
Sitecore.Resources.Media.MediaManager.GetMediaUrl(mediaItem)to get the URL of aMediaItemthen that is leveraging theSitecore.Resources.Media.MediaProvider, which pulls the value of theMediaLinkPrefixfrom theSitecore.Resources.Media.MediaConfigclass. That property does not have a ‘setter’. Furthermore, the value of that property actually comes fromSitecore.Configuration.Settings.Media.MediaLinkPrefix, which also doesn’t have a setter and is pulled directly from the config file.The
MediaManageris a static class that I believe isn’t able to be swapped out with a custom implementation. And, unlike theLinkManager, theMediaManageris hard coded to use theSitecore.Resources.Media.MediaProviderso you can’t write a custom provider either.