繁体   English   中英

我可以使用GetCropUrl从Umbraco获取图片吗?

[英]Can I get picture from Umbraco with GetCropUrl?

我已将图像上传到Umbraco,但尚未制作裁剪图像。

这只是正常的照片上传。

但是是否可以将GetCropUrl与某些参数一起使用来检索此图像? 还是我必须这样做

@if (Model.Content.HasValue("caseStudyImage"))
{
    var caseStudyImage = Model.Content.GetPropertyValue<string>("caseStudyImages");
    var caseStudyImage = Umbraco.TypedMedia(caseStudyImagesList);

    <img src="@caseStudyImage.Url" style="width:300px;height:300px" />      

}

Umbraco使用ImageProcessor,因此您可以通过在图像URL中添加适当的查询字符串参数来调整图像的大小。 因此,您可以执行以下操作:

<img src="@caseStudyImage.Url?width=300&height=300" />

您还可以通过传入图像尺寸来使用GetCropUrl方法:

<img src="@caseStudyImage.GetCropUrl(propertyAlias: "umbracoFile", height: 300, width: 300)" />

有关更多信息,请参见Umbraco文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM