Exam Area: Area 1 – Product Knowledge (15%)
Reference: https://docs.developers.optimizely.com/content-management-system/docs/image-editing
CMS 12 has a built-in image editor that allows editors to:
Media Library → Select image → Edit button (pencil icon)
└── Opens in-context image editor
// Focal point is stored with the image
// The renderer can use the focal point to crop responsively
[UIHint(UIHint.Image)]
public virtual ContentReference HeroImage { get; set; }
// In View - use focal point
@{
var imageData = _contentLoader.Get<ImageFile>(Model.CurrentPage.HeroImage);
var focalX = imageData.FocalX; // % from left
var focalY = imageData.FocalY; // % from top
}
<img src="@Url.ContentUrl(imageData.ContentLink)"
style="object-position: @(focalX)% @(focalY)%" />
jpg/jpeg, png, gif, webp, svg, bmp, tif/tiff
// Media content type for images
[ContentType(DisplayName = "Image", GUID = "...")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,png,gif,webp")]
public class ImageFile : ImageData
{
// ImageData has: Width, Height properties built-in
[Display(Name = "Alt text")]
public virtual string AltText { get; set; }
[Display(Name = "Caption")]
public virtual string Caption { get; set; }
}
ImageData class provide? (Width, Height, and base media functionality)