Contribute to Docs Contribute to Docs

Media Helper

The MediaHelper exposes helpers for accessing and manipulating uploaded media. Please note that for these methods to work you need to have registered an Image Manipulation service.

Methods

ResizeImage
@WebApp.Media.ResizeImage(ImageField image, int width, int? height = null)

Resizes the given ImageField to the specified dimensions and returns the PublicUrl to the resized file. If only width is specified the image is scaled with the same proportions. If both width and height is specified the image is both scaled and cropped.

@WebApp.Media.ResizeImage(Media image, int width, int? height = null)

Resizes the given Media to the specified dimensions and returns the PublicUrl to the resized file. If only width is specified the image is scaled with the same proportions. If both width and height is specified the image is both scaled and cropped.

@WebApp.Media.ResizeImage(ImageBlock block, int width)

Resizes the given ImageBlock to the specified width according to the preferred aspect ratio set on the block.