Change img size with changing src

Hi,
I use the Wix Code to change image on the dynamic page. New images are from URL, not Image Field, so I change it in code.
$w(‘#imagefromurl’).src = itemImgUrl;
The problem is in the size. I want to use both vertical and horizontal images, but new image is autocroped and only middle of vertical image appear on live site(cause the template has horizontal image).
The question is Could you suggest something to make new images ‘fit’ the template not ‘autocrop’?

1 Like

Okay. I’m trying to deal with it using Gallery(cause it has ‘fit’ mode).
The code is.

const itemImgUrl = $w(‘#dynamicDataset’).getCurrentItem().purtureUrl;
$w(‘#galleryFromUrl’).items = [{src: itemImgUrl}];

BUT, code works and image is shown when the gallery has ‘autocrop’ mode and it is not shown(empty gallery) without errors in console when the gallery has ‘fit’ mode.
Any ideas?