# Query, repeater and fitmode.

**URL:** <https://forum.wixstudio.com/t/query-repeater-and-fitmode/8183>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [December 27, 2022, 2:15pm UTC](https://forum.wixstudio.com/t/query-repeater-and-fitmode/8183 "2022-12-27T14:15:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefanoorazzini](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/stefanoorazzini/32/25923_2.png) [@stefanoorazzini](https://forum.wixstudio.com/u/stefanoorazzini)\
**Post date:** [December 27, 2022, 2:15pm UTC](https://forum.wixstudio.com/t/query-repeater-and-fitmode/8183/1 "2022-12-27T14:15:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![amandam](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/amandam/32/79539_2.png) [@amandam](https://forum.wixstudio.com/u/amandam)\
**Post date:** [December 28, 2022, 5:44pm UTC](https://forum.wixstudio.com/t/query-repeater-and-fitmode/8183/2 "2022-12-28T17:44:32Z")

</div>

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)

```javascript
 $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";
                }
                
                
            })

```
