I'm programatically inserting some JPGs into the Media Library with the MediaCreator
and then putting URLs to those images in a Rich Text field another item (page). When I call MediaManager.GetMediaUrl(item)
I get a URL that begins with /sitecore/shell/-/media
and the anonymous user can't see these images.
How do I get a URL to a media item that is visible to the anonymous user?
Here's my code
var mediaCreator = new MediaCreator();
var options = new MediaCreatorOptions
{
Versioned = false,
IncludeExtensionInItemName = false,
Destination = _settings.NewsMediaRootItem.Paths.ContentPath + "/" + fileName,
OverwriteExisting = true
};
using (new SecurityDisabler())
{
var item = mediaCreator.CreateFromStream(ms, fileName, options);
var uri = MediaManager.GetMediaUrl(item);
return uri;
}