Table of Contents

Class ImageFileViewModelExtensions

Namespace
Dynamicweb.Frontend
Assembly
Dynamicweb.dll

Provides extension methods for the ImageFileViewModel class.

public static class ImageFileViewModelExtensions
Inheritance
ImageFileViewModelExtensions
Inherited Members

Methods

ToBackgroundStyle(ImageFileViewModel?, GetImageSettings?, bool, string)

Converts the ImageFileViewModel instance to a CSS background style string.

public static string? ToBackgroundStyle(this ImageFileViewModel? imageFileViewModel, GetImageSettings? settings = null, bool includeBackgroundPosition = true, string backgroundSize = "cover")

Parameters

imageFileViewModel ImageFileViewModel

The ImageFileViewModel instance.

settings GetImageSettings

The settings for GetImage to control its settings like width, height and format.

includeBackgroundPosition bool

A flag indicating whether to include the background position in the style.

backgroundSize string

The background size style, default value is 'cover'. Set to null if background-size should not be set

Returns

string

A CSS background style string, or null if the image file does not exist.

ToBackgroundStyle(ImageFileViewModel?, bool)

Converts the ImageFileViewModel instance to a CSS background style string.

public static string? ToBackgroundStyle(this ImageFileViewModel? imageFileViewModel, bool includeBackgroundPosition = true)

Parameters

imageFileViewModel ImageFileViewModel

The ImageFileViewModel instance.

includeBackgroundPosition bool

A flag indicating whether to include the background position in the style.

Returns

string

A CSS background style string, or null if the image file does not exist.

ToGetImage(ImageFileViewModel?, GetImageSettings?)

Gets the relative GetImage URL for the ImageFileViewModel instance.

public static string? ToGetImage(this ImageFileViewModel? imageFileViewModel, GetImageSettings? settings = null)

Parameters

imageFileViewModel ImageFileViewModel

The ImageFileViewModel instance.

settings GetImageSettings

The settings for GetImage to control its settings like width, height and format.

Returns

string

GetImage URL e.g. /admin/public/GetImage.ashx?width=1280&format=webp&image=folder/image.jpg, or null if the image file does not exist.

Remarks

Default format is webp and default width is 1280 if no settings object instance is passed

To top