# Resolved - Images in ProGallery not always appearing (on.ready related?)

**URL:** <https://forum.wixstudio.com/t/resolved-images-in-progallery-not-always-appearing-on-ready-related/34555>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [September 28, 2020, 4:49pm UTC](https://forum.wixstudio.com/t/resolved-images-in-progallery-not-always-appearing-on-ready-related/34555 "2020-09-28T16:49:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![exequielbertaina](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/exequielbertaina/32/9484_2.png) [@exequielbertaina](https://forum.wixstudio.com/u/exequielbertaina)\
**Post date:** [September 28, 2020, 4:49pm UTC](https://forum.wixstudio.com/t/resolved-images-in-progallery-not-always-appearing-on-ready-related/34555/1 "2020-09-28T16:49:41Z")

</div>

Hi,  
I currently have an issue where the images inside a Wix Pro Gallery don’t always appear (both editor/live mode) and I suspect it has something to do with the data not being ready to be manipulated. What I mean by that is I’m trying to randomize the order of the photos displayed and sometimes that gallery will be blank. I’ve noticed by logging the info that sometimes the _items_ array = 0, before things start to get randomized.

The following code:

```javascript
$w.onReady( () => {
    $w("#dataset3").onReady(() => {
       let items = $w("#gallery1").items;
       //console.log(items)
       items = shuffle(items);
       $w("#gallery1").items = items;
    });
});
export function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
 const j = Math.floor(Math.random() * (i + 1));
   [array[i], array[j]] = [array[j], array[i]];
}
return array;
}

```

Since the Pro Gallery is below the fold or the page is not done loading, is there a way to put some sort of condition to ensure the ITEMS variable will contain the images before the shuffling function proceeds?

Thanks for your time  
Webpage: [emunations.com/gliden64](http://emunations.com/gliden64)

---

<div class="post-metadata">

**Author:** ![exequielbertaina](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/exequielbertaina/32/9484_2.png) [@exequielbertaina](https://forum.wixstudio.com/u/exequielbertaina)\
**Post date:** [September 29, 2020, 8:56pm UTC](https://forum.wixstudio.com/t/resolved-images-in-progallery-not-always-appearing-on-ready-related/34555/2 "2020-09-29T20:56:04Z")

</div>

It seems to have resolved via this

```javascript
  ...
      wixData.query("xxxxxx")
        .eq("title", "xxxxxxx")
        .find()
        .then((results)=> {
 let items = results.items[0].gallery;   
        items = shuffle(items);
        $w("#gallery1").items = items;  
    });   
})
export function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
 const j = Math.floor(Math.random() * (i + 1));
   [array[i], array[j]] = [array[j], array[i]];
}
return array;
}

```
