Set of editors for EPiServer to allow editor to crop images on the fly.
##Editors
- Single Image
- Multiple Image
Install-Package ITMeric.ImageCrop
The package can be found in the EPiServer Nuget Feed.
Example usage:
[ImageReference(CropRatio = 1d, AllowedTypes = new [] { typeof(ImageFile)})]
public virtual ImageReference SingleImageReference { get; set; }
[ImageReference(CropRatio = 1d, AllowedTypes = new[] { typeof(ImageFile) })]
public virtual ImageReferenceList ImageReferenceList { get; set; }
Render image (Markup):
The easiest way to render a cropped image is to use GetCropUrl
extension method:
@model ITMeric.ImageCrop.Core.ImageReference
<img src="@Model.CurrentPage.SingleImageReference.GetCropUrl(width: 100, height: 100)" />
In case you need to provide a fallback image, you can specify fallback optional paramters as follows:
<img src="@Model.CurrentPage.SingleImageReference.GetCropUrl(width: 100, height: 100, fallback: "/fallback.jpg")" />