sitecore开发入门之如何在代码中获取SITECORE图像URL
using Sitecore; using Sitecore.Data.Items; using Sitecore.Resources.Media; public string GetUrl() { var currentItem = Sitecore.Context.Item; var imageUrl = string.Empty; Sitecore.Data.Fields.ImageField imageField = currentItem.Fields["Image"]; if (imageField?.MediaItem != null) { var image = new MediaItem(imageField.MediaItem); imageUrl = StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(image)); } }
sitecore