Query, repeater and fitmode.

Hi all,

I selected 4 photos from my “Images” database.

Now, i would like select a different fitmode (‘fit’ for vertical images and ‘fixedwidth’ for horizontal images.)

I have a field (named HV) with a value of h (horizontal) and v (vertical).

What can I do? I thought about using foreachitem, but I can’t implement it.

This is my code:

$w . onReady (() => {

let galpicture = $w ( “#dynamicDataset” ). getCurrentItem ();

$w . onReady ( function () {
$w ( “#repeater1” ). onItemReady ( ( $item , itemData , index ) => {
$item ( “#image1” ). src = itemData . Photoimage ;
$item ( “#text1” ). text = itemData . title ;
} );

wixData . query ( “Images” )
. contains ( “gallery” , galpicture . gallery )
. ne ( “title” , galpicture . title )
. ascending ( “photoOrder” )
. limit ( 4 )
. find ()
. then ( ( results ) => {
$w ( “#repeater1” ). data = results . items ;
});
});
});

Many thanks for considering my request.

Stefano

Hello, if I"m understanding correctly, this is what you are looking for…
After you set results.items to your repeater data, you will need to do something like this (pseudocode, untested)

 $w('#repeater1').onItemReady(($item, itemData, index) => {
 //manually populate all your items in your repeater here including the fitMode
                $item("#image").src = itemData.source;
                if(image meets whatever criteria){
                $item("#image").fitMode = "fixedWidth";
                }
                else{
                $item("#image").fitMode = "some other fit";
                }
                
                
            })