首页 > 代码库 > Sitecore Resize Image Size
Sitecore Resize Image Size
<asp:Image ID="VideoImg" runat="server" Width="269" Height="152" ResizeWidth="269"/>
videoImg.ImageUrl = SitecoreHelper.GetMediaUrlforImageField(curItem.Fields["Image Info"]) + "?w=" + videoImg.Attributes["ResizeWidth"];
public static string GetMediaUrlforImageField(Sitecore.Data.Fields.ImageField field)
{
if (field != null && field.MediaItem != null)
{
MediaItem media = new MediaItem(field.MediaItem);
return MediaManager.GetMediaUrl(media);
}
return "";
}
public static string GetMediaId(Sitecore.Data.Fields.ImageField field)
{
if (field != null && field.MediaItem != null)
{
MediaItem media = new MediaItem(field.MediaItem);
string mediaId = media.ID.ToString();
return mediaId;
}
return "";
}
Sitecore Resize Image Size