Class ImageCropperValue
Represents a value of the image cropper value editor.
Namespace: Umbraco.Cms.Core.PropertyEditors.ValueConverters
Assembly: Umbraco.Infrastructure.dll
Syntax
public class ImageCropperValue : TemporaryFileUploadValueBase, IHtmlEncodedString
Constructors
View SourceImageCropperValue()
Declaration
public ImageCropperValue()
Properties
View SourceCrops
Gets or sets the value crops.
Declaration
public IEnumerable<ImageCropperValue.ImageCropperCrop>? Crops { get; set; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ImageCropperValue.ImageCropperCrop> |
FocalPoint
Gets or sets the value focal point.
Declaration
public ImageCropperValue.ImageCropperFocalPoint? FocalPoint { get; set; }
Property Value
| Type | Description |
|---|---|
| ImageCropperValue.ImageCropperFocalPoint |
Methods
View SourceEquals(object?)
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Equals(ImageCropperValue?)
Declaration
public bool Equals(ImageCropperValue? other)
Parameters
| Type | Name | Description |
|---|---|---|
| ImageCropperValue | other |
Returns
| Type | Description |
|---|---|
| bool |
GetCrop(string?)
Gets a crop.
Declaration
public ImageCropperValue.ImageCropperCrop? GetCrop(string? alias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias |
Returns
| Type | Description |
|---|---|
| ImageCropperValue.ImageCropperCrop |
GetCropBaseOptions(string?, ImageCropperCrop?, bool)
Creates and returns image URL generation options based on the provided image URL, crop information, and focal point preference.
If preferFocalPoint is true and a focal point is available, or if the crop is specified without coordinates and a focal point exists, the returned options will use the focal point.
If crop coordinates are provided and preferFocalPoint is false, the returned options will use the crop coordinates.
Otherwise, default options are returned.
Declaration
public ImageUrlGenerationOptions GetCropBaseOptions(string? url, ImageCropperValue.ImageCropperCrop? crop, bool preferFocalPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL of the image. |
| ImageCropperValue.ImageCropperCrop | crop | The crop information to apply to the image, or |
| bool | preferFocalPoint | If |
Returns
| Type | Description |
|---|---|
| ImageUrlGenerationOptions | An Umbraco.Cms.Core.PropertyEditors.ValueConverters.ImageUrlGenerationOptions instance configured with either the focal point, crop coordinates, or default settings based on the input parameters. |
GetCropUrl(int, int, IImageUrlGenerator, string?)
Gets the value image URL for a specific width and height.
Declaration
public string? GetCropUrl(int width, int height, IImageUrlGenerator imageUrlGenerator, string? cacheBusterValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | |
| int | height | |
| IImageUrlGenerator | imageUrlGenerator | |
| string | cacheBusterValue |
Returns
| Type | Description |
|---|---|
| string |
GetCropUrl(string, IImageUrlGenerator, bool, bool, string?)
Returns the image URL for the specified crop alias using the provided image URL generator.
Declaration
public string? GetCropUrl(string alias, IImageUrlGenerator imageUrlGenerator, bool useCropDimensions = true, bool useFocalPoint = false, string? cacheBusterValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias | The alias of the crop to retrieve the URL for. If empty or not found, the original image or focal point may be used. |
| IImageUrlGenerator | imageUrlGenerator | The image URL generator used to construct the URL. |
| bool | useCropDimensions | If true, the crop's width and height are used in the generated URL; otherwise, dimensions are not applied. |
| bool | useFocalPoint | If true, the focal point is used in URL generation. If false, the crop's coordinates are used if available. |
| string | cacheBusterValue | An optional value appended to the URL to prevent caching issues. |
Returns
| Type | Description |
|---|---|
| string | The URL of the cropped image if the crop is found; otherwise, null if the specified crop alias does not exist. |
GetHashCode()
Returns a hash code for this ImageCropperValue instance, based on its property values.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code representing the current ImageCropperValue object. |
HasCrop(string)
Determines whether a crop with the specified alias exists in the value.
Declaration
public bool HasCrop(string alias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias | The alias of the crop to check for. |
Returns
| Type | Description |
|---|---|
| bool |
|
HasCrops()
Determines whether the value has crops.
Declaration
public bool HasCrops()
Returns
| Type | Description |
|---|---|
| bool |
|
HasFocalPoint()
Determines whether the value has a focal point.
Declaration
public bool HasFocalPoint()
Returns
| Type | Description |
|---|---|
| bool |
HasImage()
Checks if the value contains a source image.
Declaration
public bool HasImage()
Returns
| Type | Description |
|---|---|
| bool | Returns |
Merge(ImageCropperValue)
Merges the current ImageCropperValue instance with another, combining their crops and properties.
Crops from the provided imageCropperValue are added if they do not exist in the current instance, or their coordinates are used if missing in the current crop.
The Src property is taken from the current instance if available; otherwise, it falls back to the provided value.
The FocalPoint is taken from the current instance if set; otherwise, it uses the provided value.
Declaration
public ImageCropperValue Merge(ImageCropperValue imageCropperValue)
Parameters
| Type | Name | Description |
|---|---|---|
| ImageCropperValue | imageCropperValue | The ImageCropperValue to merge with the current instance. |
Returns
| Type | Description |
|---|---|
| ImageCropperValue | A new ImageCropperValue instance containing the merged crops and properties. |
ToHtmlString()
Returns an HTML-encoded string.
Declaration
public string? ToHtmlString()
Returns
| Type | Description |
|---|---|
| string | An HTML-encoded string. |
ToString()
Returns the image source URL represented by this ImageCropperValue.
Declaration
public override string? ToString()
Returns
| Type | Description |
|---|---|
| string | The image source URL if available; otherwise, |
Operators
View Sourceoperator ==(ImageCropperValue?, ImageCropperValue?)
Declaration
public static bool operator ==(ImageCropperValue? left, ImageCropperValue? right)
Parameters
| Type | Name | Description |
|---|---|---|
| ImageCropperValue | left | |
| ImageCropperValue | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(ImageCropperValue?, ImageCropperValue?)
Declaration
public static bool operator !=(ImageCropperValue? left, ImageCropperValue? right)
Parameters
| Type | Name | Description |
|---|---|---|
| ImageCropperValue | left | |
| ImageCropperValue | right |
Returns
| Type | Description |
|---|---|
| bool |