Coding Issues with Images in Repeater

Hi. I have asked for some help getting images in my repeater to show all in the same sizes. Currently I have both images of buildings and logos in the same repeater and some are landscape, some are portrait, all various sizes.

The code that I was given to include on the page for this fix is:

However, I must not be inserting it at the correct location because it is not adjusting for me.

Do I need to be adding it somewhere else because of the repeater? The images pull from a database in the repeater.

Here is what the code looks like now on the page. I’m sorry I’m not a great coder. Can anyone help?

// For full API documentation, including code examples, visit http://wix.to/94BuAAs$w.onReady(function () {
$w ( “#myImage” ). fitMode = “fit” ;

/**

  • Adds an event handler that runs when an element is displayed
    in the viewable part of the current window.
    Read more
  • @param {Event} event

/**

  • Adds an event handler that runs when the dataset is ready.
    */

I was told that I need to set the fitMode to fit in your code panel and to make sure to add the code in the onReady callback. But I am getting an error in the code and it’s not working.

Thanks.

The Wix Velo Forum (coding forum) is probably the best place to ask - https://www.wix.com/velo/forum/coding-with-velo

Although, if these images are in a repeater and are being pulled from a database then they all should be showing at the same size without the need for code.

I work alottttt with repeaters and databases, so if you need any help, let me know. (You should find my details in my profile) :facepunch:

For anyone who needs this in the future. Here is the code that you will need:

$w.onReady(() => {
    $w("#dataset1").onReady(() => {
    $w("#repeater1").forEachItem(($item, itemData, index) => {
        $item("#image1").fitMode = "fit";
    })
    })
})

Replace #myRepeater and #myImage with the id of those elements on your site.