本文整理汇总了C#中IPublishedContent.GetCropUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IPublishedContent.GetCropUrl方法的具体用法?C# IPublishedContent.GetCropUrl怎么用?C# IPublishedContent.GetCropUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPublishedContent
的用法示例。
在下文中一共展示了IPublishedContent.GetCropUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImagePickerImage
/// <summary>
/// Initializes a new instance based on the specified <code>content</code>.
/// </summary>
/// <param name="content">An instance of <see cref="IPublishedContent"/> representing the selected image.</param>
protected ImagePickerImage(IPublishedContent content) {
Image = content;
Width = content.GetPropertyValue<int>(global::Umbraco.Core.Constants.Conventions.Media.Width);
Height = content.GetPropertyValue<int>(global::Umbraco.Core.Constants.Conventions.Media.Height);
Url = content.Url;
CropUrl = content.GetCropUrl(Width, Height, preferFocalPoint: true, imageCropMode: ImageCropMode.Crop);
}
示例2: MapImageCrops
/// <summary>
/// Map image crops model
/// </summary>
/// <param name="media">Media node</param>
/// <param name="image">Image model</param>
private static void MapImageCrops(IPublishedContent media, ImageViewModel image)
{
if (media == null)
{
return;
}
var imageString = media.GetPropertyValue<string>(PropertyAliases.UmbracoFile);
var imageCrops = JsonHelper.Deserialize<ImageCropperModel>(imageString);
image.Crops = imageCrops.Crops.ToDictionary(x => x.Alias, x => media.GetCropUrl(x.Alias));
}