Rudhycodes
Rudhycodes

Reputation: 1

2SXC Image Format Not Updating

Problem:

I'm using the @Kit.Image.Picture() method to render an image with specific settings. My goal is to force the image to be in the WebP format. Here’s the code snippet I’m using:

@Kit.Image.Picture(image, width: "390", settings: "NewsList", imgAlt: altText)

When selecting an image format (e.g., WebP or PNG) via the Two Signals interface, the Format property in IResizeSettings is not updated. This results in the generated URL not including the ?format= parameter, and the image is served in its default format.

Settings Framework Details:

I'm relying on the Settings method for constructing resize settings. The following format-related parameters are documented and available:

IResizeSettings Settings(object settings = null, NoParamOrder noParamOrder = default, Func<ITweakResize, ITweakResize> tweak = null, object factor = null, object width = null, object height = null, object quality = null, string resizeMode = null, string scaleMode = null, string format = null, object aspectRatio = null, string parameters = null, object recipe = null)

In the documentation, the format parameter should allow me to specify a target format (e.g., webp or png <string>). However, when I specify WebP, the resulting image does not update to the WebP format.

Expected Outcome:

The generated image URLs should include the .webp extension, indicating that the images are served in the WebP format.

Actual Outcome:

The image URLs remain unchanged, and the images are not served in the WebP format as intended.

Setting in 2SXC App Setting
ImageResizer URL unchanged

Upvotes: -1

Views: 38

Answers (2)

MBouwman
MBouwman

Reputation: 69

When I do something like:

 var customSettingsMax = AsDynamic(new {
    Width = 350,
    ResizeMode = "Max",
    format= "webp",
    quality= 100
  });

<img loading="lazy" src='@Link.Image(imgUrl, customSettingsMax)'>

It wil not generate a webp. However, when I do:

<img loading="lazy" src='@Link.Image(imgUrl, customSettingsMax, format: "webp")'>

It will, so I think the format setting is ignored somewhere....

Upvotes: 1

iJungleBoy
iJungleBoy

Reputation: 5638

(note: I accidentally wrote an answer to an other issue here first)

My understanding is what you are doing should work.

My guess is you made a mistake - such as changing the configuration for NewsList images (as in the screenshot), but not using that name in your Razor code, in which case the settings for Default are used.

So I would check that first.

Upvotes: 0

Related Questions