Class ImageExtensions
Extension methods for adaptive image properties.
Inheritance
ImageExtensions
Assembly: AdaptiveImages.dll
Syntax
public static class ImageExtensions
Methods
AssignTo(SingleImage, AdaptiveImage)
Copies all properties from one SingleImage instance to each form factor of an AdaptiveImage instance.
Declaration
public static void AssignTo(this SingleImage image, AdaptiveImage property)
Parameters
AssignTo(SingleImage, SingleImage)
Copies all properties from one SingleImage instance to another.
Declaration
public static void AssignTo(this SingleImage image, SingleImage property)
Parameters
GetCropSettings(SingleImage)
Gets crop settings for an image and calculates the resulting cropped image size based on the image's original file size.
Declaration
public static CropSettings GetCropSettings(this SingleImage image)
Parameters
Returns
GetCropSettings<TImage, TProperty>(TImage, Expression<Func<TImage, TProperty>>)
Calculates the dimensions of a cropped image based on its crop settings, if any.
Declaration
public static CropSettings GetCropSettings<TImage, TProperty>(this TImage image, Expression<Func<TImage, TProperty>> expression) where TImage : AdaptiveImage where TProperty : SingleImage
Parameters
Type |
Name |
Description |
TImage |
image |
|
Expression<Func<TImage, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TImage |
|
TProperty |
|
GetCultureSpecificImageAttribute<TContent, TProperty>(TContent, Expression<Func<TContent, TProperty>>)
Declaration
public static CultureSpecificImageAttribute? GetCultureSpecificImageAttribute<TContent, TProperty>(this TContent content, Expression<Func<TContent, TProperty>> expression)
Parameters
Type |
Name |
Description |
TContent |
content |
|
Expression<Func<TContent, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TContent |
|
TProperty |
|
Used to resolve a form factor based on its name.
Declaration
public static FormFactor GetFormFactor(string name)
Parameters
Type |
Name |
Description |
string |
name |
|
Returns
Identifies the correct form factor for an image details property.
Declaration
public static FormFactor GetFormFactor<TImage, TProperty>(this TImage image, Expression<Func<TImage, TProperty>> expression) where TImage : AdaptiveImage where TProperty : SingleImage
Parameters
Type |
Name |
Description |
TImage |
image |
|
Expression<Func<TImage, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TImage |
|
TProperty |
|
Gets image details for a specific form factor.
Declaration
public static SingleImage GetImageByFormFactor<T>(this T adaptiveImage, FormFactor formFactor) where T : AdaptiveImage
Parameters
Type |
Name |
Description |
T |
adaptiveImage |
|
FormFactor |
formFactor |
|
Returns
Type Parameters
Gets image details for a specific form factor.
Declaration
public static SingleImage GetImageByFormFactor<TContent, TProperty>(this TContent content, Expression<Func<TContent, TProperty>> expression, FormFactor formFactor) where TContent : AdaptiveImage where TProperty : AdaptiveImage
Parameters
Returns
Type Parameters
Name |
Description |
TContent |
|
TProperty |
|
GetImageConstraints(MemberInfo)
Gets image constraints for a specific property .
Declaration
public static ImageConstraints GetImageConstraints(this MemberInfo memberInfo)
Parameters
Returns
GetImageConstraints<TParent>(TParent, string)
Gets image constraints for a specific property.
Declaration
public static ImageConstraints GetImageConstraints<TParent>(this TParent parent, string propertyName) where TParent : class
Parameters
Type |
Name |
Description |
TParent |
parent |
|
string |
propertyName |
|
Returns
Type Parameters
Exceptions
GetImageConstraints<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>)
Gets image constraints for a specific property.
Declaration
public static ImageConstraints GetImageConstraints<TParent, TProperty>(this TParent parent, Expression<Func<TParent, TProperty>> expression) where TParent : class where TProperty : AdaptiveImage
Parameters
Type |
Name |
Description |
TParent |
parent |
|
Expression<Func<TParent, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TParent |
|
TProperty |
|
Exceptions
GetImageRenderSettings<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>)
Declaration
public static ImageRenderSettings GetImageRenderSettings<TParent, TProperty>(this TParent parent, Expression<Func<TParent, TProperty>> expression) where TParent : class where TProperty : SingleImage
Parameters
Type |
Name |
Description |
TParent |
parent |
|
Expression<Func<TParent, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TParent |
|
TProperty |
|
Examples
ImageRenderSettings renderSettings = currentContent.GetImageRenderSettings(x => x.MySingleImage)
Declaration
public static ImageRenderSettings GetImageRenderSettings<TParent, TProperty>(this TParent parent, Expression<Func<TParent, TProperty>> expression, FormFactor formFactor) where TParent : class where TProperty : AdaptiveImage
Parameters
Type |
Name |
Description |
TParent |
parent |
|
Expression<Func<TParent, TProperty>> |
expression |
|
FormFactor |
formFactor |
Form factor for which render settings should be created.
|
Returns
Type |
Description |
ImageRenderSettings |
Default settings for rendering the image of a specific form factor.
|
Type Parameters
Name |
Description |
TParent |
|
TProperty |
|
ImageRenderSettings renderSettings = currentContent.GetImageRenderSettings(x => x.MyAdaptiveImage, FormFactor.Large)
GetProportionsConstraint<TParent>(TParent, string)
Used to get proportions constraints, if any, for a single image.
Declaration
public static ProportionsAttribute? GetProportionsConstraint<TParent>(this TParent parent, string singleImagePropertyName) where TParent : class
Parameters
Type |
Name |
Description |
TParent |
parent |
|
string |
singleImagePropertyName |
|
Returns
Type Parameters
Used to get proportions constraint, if any, for a specific form factor.
Declaration
public static ProportionsAttribute? GetProportionsConstraint<TParent>(this TParent parent, string adaptiveImagePropertyName, FormFactor formFactor) where TParent : class
Parameters
Type |
Name |
Description |
TParent |
parent |
|
string |
adaptiveImagePropertyName |
|
FormFactor |
formFactor |
|
Returns
Type Parameters
GetProportionsConstraint<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>)
Get proportions contraint, if any, for a single form factor.
Declaration
public static ProportionsAttribute? GetProportionsConstraint<TParent, TProperty>(this TParent parent, Expression<Func<TParent, TProperty>> expression) where TParent : class where TProperty : SingleImage
Parameters
Type |
Name |
Description |
TParent |
parent |
|
Expression<Func<TParent, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TParent |
|
TProperty |
|
GetRequiredImageAttribute<TContent, TProperty>(TContent, Expression<Func<TContent, TProperty>>)
Declaration
public static RequiredImageAttribute? GetRequiredImageAttribute<TContent, TProperty>(this TContent content, Expression<Func<TContent, TProperty>> expression)
Parameters
Type |
Name |
Description |
TContent |
content |
|
Expression<Func<TContent, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TContent |
|
TProperty |
|
GetSizeConstraint(IContentData, string)
Used to get size constraints, if any, for a single image.
Declaration
public static SizeAttribute? GetSizeConstraint(this IContentData content, string singleImagePropertyName)
Parameters
Type |
Name |
Description |
IContentData |
content |
|
string |
singleImagePropertyName |
|
Returns
GetSizeConstraint(IContentData, string, FormFactor)
Used to get size constraints, if any, for a specific form factor.
Declaration
public static SizeAttribute? GetSizeConstraint(this IContentData content, string adaptiveImagePropertyName, FormFactor formFactor)
Parameters
Type |
Name |
Description |
IContentData |
content |
|
string |
adaptiveImagePropertyName |
|
FormFactor |
formFactor |
|
Returns
GetSizeConstraint<TContent, TProperty>(TContent, Expression<Func<TContent, TProperty>>)
Get size contraints, if any, for a single form factor.
Declaration
public static SizeAttribute? GetSizeConstraint<TContent, TProperty>(this TContent content, Expression<Func<TContent, TProperty>> expression) where TProperty : SingleImage
Parameters
Type |
Name |
Description |
TContent |
content |
|
Expression<Func<TContent, TProperty>> |
expression |
|
Returns
Type Parameters
Name |
Description |
TContent |
Normally the content type that defines the SingleImage property
|
TProperty |
The SingleImage property for which any size attribute should be resolved
|
HasFocalPoint(SingleImage)
Checks if an image has an explicitly set focal point.
Declaration
public static bool HasFocalPoint(this SingleImage image)
Parameters
Returns
IsCropped(SingleImage)
Checks if image has been manually cropped.
Declaration
public static bool IsCropped(this SingleImage image)
Parameters
Returns
IsSet(AdaptiveImage?)
Checks if adaptive image has an image set for all form factors.
Declaration
public static bool IsSet(this AdaptiveImage? image)
Parameters
Returns
IsSet(SingleImage?)
Checks if the image has a valid image set.
Declaration
public static bool IsSet(this SingleImage? image)
Parameters
Returns
Declaration
public static string ToJson(this AdaptiveImage image, Formatting formatting = Formatting.None)
Parameters
Returns
Declaration
public static string ToJson(this SingleImage image, Formatting formatting = Formatting.None)
Parameters
Type |
Name |
Description |
SingleImage |
image |
|
Formatting |
formatting |
|
Returns