码迷,mamicode.com
首页 > Web开发 > 详细

Umbraco image中使用Crop URL

时间:2017-05-25 09:56:12      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:etc   lis   str   aced   package   blog   pretty   ted   model   

需要在Umbraco 的image中使用crop URL.首先你需要取出这个image作为IPublishedContent

有以下两种方法

第一种:

var imageId = Model.Content.GetPropertyValue<int>("image");
var image = Umbraco.TypedMedia(imageId);

第二种,如果你已经使用了Core Property Value Converters package, 你可以直接取出

var image = Model.Content.GetPropertyValue<IPublishedContent>("image");

You then need to call the GetCropUrl() method on your image. If you‘ve replaced the default Upload property with an Image Cropper property, and kept the property alias the same (umbracoFile), you can just pass in the crop alias:

var cropUrl = image.GetCropUrl("my-crop-name");

If the alias of your Image Cropper property is different to the default you will need to pass that as an additional argument:

var cropUrl = image.GetCropUrl("imageCropperAlias", "my-crop-name");

Umbraco image中使用Crop URL

标签:etc   lis   str   aced   package   blog   pretty   ted   model   

原文地址:http://www.cnblogs.com/wphl-27/p/6901812.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!