The following example (and the ones after this) will use a flatter image to make it easier to see all the samples. To achieve this, we must create ResizeSettings
for this. It will be based on the default Content
settings.
-
-
-
To see the currentSrc change, make the window narrow, reload, and then drag it to become larger.
image src should appear here
@inherits Custom.Hybrid.Razor14
@{
var imgPath = App.Path + "/assets/img-resize";
var tomatoPicUrl = imgPath + "/tomatoes.jpg";
var flatSettings = Kit.Image.Settings("Content", aspectRatio: "8:1");
}
@Kit.Image.Img(tomatoPicUrl, settings: flatSettings)
<img src='/Portals/tutorials/2sxc/Tutorial-Razor/assets/img-resize/tomatoes.jpg?w=1230&h=153&quality=75&mode=crop&scale=both'
loading='lazy'
class='img-fluid'
width='1230'
height='153'
srcset='/Portals/tutorials/2sxc/Tutorial-Razor/assets/img-resize/tomatoes.jpg?w=2460&h=307&quality=75&mode=crop&scale=both 2460w,
/Portals/tutorials/2sxc/Tutorial-Razor/assets/img-resize/tomatoes.jpg?w=1230&h=153&quality=75&mode=crop&scale=both 1230w,
/Portals/tutorials/2sxc/Tutorial-Razor/assets/img-resize/tomatoes.jpg?w=922&h=115&quality=75&mode=crop&scale=both 922w,
/Portals/tutorials/2sxc/Tutorial-Razor/assets/img-resize/tomatoes.jpg?w=615&h=76&quality=75&mode=crop&scale=both 615w'
sizes='(max-width: 1400px) 100vw,
1230px'>