Image Resizing

By default, the blob datas for media will be the same as you uploaded by calling the blob url:

/public/blob?id=4277b1e4-f50b-487d-b535-470d3b693217

 

Resizing images

To resize images, add these parameters:

  • w - for the width
  • h - for the height
  • mode - crop or contain (default: contain)

Example url might be: /public/blob?id=4277b1e4-f50b-487d-b535-470d3b693217&w=250&h=250

 

Allow Image sizes

To secure and prevent flooding the media cache, the allowed dimensions must be configured in the appsettings. Otherwise it will be ignored.

{
  "NLESS.IO": {
    "ImageResizing": {
      "AllowOriginalDimension": true,
      "AllowedDimensions": [
        {
          "Width": 250,
          "Height": 250
        },
        {
          "Width": 400,
          "Height": 250
        },
        {
          "Width": 400,
          "Height": 400
        },
        {
          "Width": 1920,
          "Height": 600
        }
      ]
    }
  }
}

Using in razor views

For generating the media url, there is a helper method:

<img src="@imageUrl?.Url(width: 250, height: 250)"/>