Class SingleImage
Represents a single image, either independently or as a form factor of an AdaptiveImage.
Implements
Inherited Members
Namespace: AdaptiveImages.Models
Assembly: AdaptiveImages.dll
Syntax
[ContentType(GUID = "bb4ba9aa-aa76-4167-91af-9e1f297076fb", AvailableInEditMode = false, GroupName = "AdaptiveImages", Order = 10010)]
[JsonConverter(typeof(SingleImageConverter))]
[JsonConverter(typeof(SingleImageConverter))]
public class SingleImage : BlockData, IContentData, IInitializableContent, IModifiedTrackable, IReadOnly<BlockData>, IReadOnly, IEquatable<SingleImage>
Constructors
SingleImage()
Creates an empty instance without any configuration settings.
Declaration
public SingleImage()
SingleImage(IAddonSettings?)
Creates an empty instance with specific configuration settings.
Declaration
public SingleImage(IAddonSettings? addonSettings)
Parameters
Type | Name | Description |
---|---|---|
IAddonSettings | addonSettings | Settings to use if different from the IAddonSettings available through the DI container. |
SingleImage(ContentReference)
Creates an image based on an existing Optimizely image.
Declaration
public SingleImage(ContentReference contentLink)
Parameters
Type | Name | Description |
---|---|---|
ContentReference | contentLink | EPiServer.Core.ContentReference for an EPiServer.Core.ImageData instance. |
Remarks
This constructor is primarily intended for fallback scenarios where new SingleImage properties should fall back to existing Optimizely image properties.
Properties
AlternateText
Gets or sets an image description to render as alt attribute on img elements.
Declaration
[CultureSpecific]
public virtual string? AlternateText { get; set; }
Property Value
Type | Description |
---|---|
string |
Bottom
Gets or sets cropping from the bottom, relative to original image width. A value of 0.25 would make the top 75% of the original image visible, unless image is also cropped from the top.
Declaration
[Range(0, 1)]
[CultureSpecific]
public virtual double? Bottom { get; set; }
Property Value
Type | Description |
---|---|
double? |
Filename
Gets or sets a filename to include in the image URL, for example to improve on-site SEO.
Declaration
[CultureSpecific]
public virtual string? Filename { get; set; }
Property Value
Type | Description |
---|---|
string |
FocalPointX
Gets or sets a relative focal point X coordinate. A value of 0.5 means the focal point is in the center of the original image horizontally.
Declaration
[Range(0, 1)]
[CultureSpecific]
public virtual double? FocalPointX { get; set; }
Property Value
Type | Description |
---|---|
double? |
FocalPointY
Gets or sets a relative focal point Y coordinate. A value of 0.5 means the focal point is in the center of the original image vertically.
Declaration
[Range(0, 1)]
[CultureSpecific]
public virtual double? FocalPointY { get; set; }
Property Value
Type | Description |
---|---|
double? |
Height
Gets or sets the width of the original image.
Declaration
[CultureSpecific]
public virtual int Height { get; set; }
Property Value
Type | Description |
---|---|
int |
Id
Gets or sets the identifier of the original image asset.
Declaration
[CultureSpecific]
public virtual string? Id { get; set; }
Property Value
Type | Description |
---|---|
string |
Left
Gets or sets cropping from the left, relative to original image width.
Declaration
[Range(0, 1)]
[CultureSpecific]
public virtual double? Left { get; set; }
Property Value
Type | Description |
---|---|
double? |
Provider
Gets or sets the name of the source image provider.
Declaration
[CultureSpecific]
public virtual string? Provider { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
Defaults to DefaultProviderName if not set.
Right
Gets or sets cropping from the right, relative to original image width. A value of 0.25 would make the left 75% of the original image visible, unless image is also cropped from the left.
Declaration
[Range(0, 1)]
[CultureSpecific]
public virtual double? Right { get; set; }
Property Value
Type | Description |
---|---|
double? |
Top
Gets or sets cropping from the top, relative to original image width.
Declaration
[Range(0, 1)]
[CultureSpecific]
public virtual double? Top { get; set; }
Property Value
Type | Description |
---|---|
double? |
Width
Gets or sets the width of the original image.
Declaration
[CultureSpecific]
public virtual int Width { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
Equals(SingleImage?)
Compares to SingleImage objects by validating all properties, including crop points, are identical.
Declaration
public bool Equals(SingleImage? other)
Parameters
Type | Name | Description |
---|---|---|
SingleImage | other | The other SingleImage to compare to. |
Returns
Type | Description |
---|---|
bool |