Coding a Pro Gallery direct from Media Gallery field type

I was wondering if it is possible to code the pro gallery direct, I have come across various posts about coding individual images in separate field keys to a normal gallery. The reason i ask is that I currently have two pro gallerys but this slows the page load speed, if I remove one it speeds up by about 3 seconds.

So just wondering if I can toggle between them using a button
This is the code similar to what I used to used with separate gallery images within the database.

 $w.onReady(function () {  
let item = $w("#dynamicDataset").getCurrentItem();        
 $w("#gallery1").items = [          
{src: item.image1, title: item.image_title1, description: item.image_desc1},         
{src: item.image2, title: item.image_title2, description: item.image_desc2},         
{src: item.image3, title: item.image_title3, description: item.image_desc3},         
{src: item.image4, title: item.image_title4, description: item.image_desc4},         
{src: item.image5, title: item.image_title5, description: item.image_desc5},         
{src: item.image6, title: item.image_title6, description: item.image_desc6}       
];  
}); 

I just wondered if there is something similar for the pro gallery and using mediaGallery Field Type?

Best wishes

Stephen

There is two media gallery with a field key “image” and “image2”
Used if statement to act as a toggle
https://salman2301.wixsite.com/gallery

$w.onReady(function () {
	 $w('#dataset1').onReady(() => {
	 $w('#gallery1').items = $w('#dataset1').getCurrentItem().image
		 $w('#button1').onClick(() => {
			if($w('#button1').label === 'Gallery 1') {
				$w('#button1').label = 'Gallery 2';
				 $w('#gallery1').items = $w('#dataset1').getCurrentItem().image2
			} else {
				 $w('#gallery1').items = $w('#dataset1').getCurrentItem().image
			}
		 });
	 })
});

Thanks @salman-hammed !

I was wondering how to populate the titles and descriptions also?
I will be using two separate buttons to display other content also but get the concept.
I take it that the
.image & .image2
is your field key for your media gallery?

@stephenmccall Yes it is image and image2 are the field key of the media gallery.

@salman-hammed thank you :slight_smile:
Is it pretty straight forward to code the title and descriptions? Same code but use .title and .description to populate?

Hey @salman-hammed , I got in front of my computer, all sorted now :slight_smile: thank you!