How can I search for images in Pro Gallery

I have a collection with Fields for the following :

Title - The title of the category of images eg Birthday Cards, Christmas

Gallery - The gallery where the images are for each category (ie the title field)

I want to be able to search in all categories for keywords or tags so for example if a user puts in the keyword “red” into a search box , it needs to search all categories for any image with the keywords “red” in them and display them as thumbnails in the search results

A screen shot of the collection is shown below :

Did you already have worked with code?

If you never have worked with code before, this will be a very difficult task for you.

How to get your goal ?

  1. Create your ProGallary on your site (page).
  2. Modify all your ProGallary-Items like you want, directly inside of your ProGallary.
  3. Create a BACKEND-FILE → called proGallary.jsw.
  4. Write some code for the backend to get your wished functionality…

a) You will need the ProGallary-ID first (but how and where to get it?)
Generate a CODE which will get a list of all your GALLARIES…

export async function myListGalleriesFunction() {
  try {
    let galleryList = await proGallery.listGalleries();
    return galleryList;
    
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

…or… get the GALLARY-ID directly from the PROPERTY-PANEL of your ProGallary inside of the Wix-Editor, by a click onto your → ProGallaray → SUPPORT -->scroll down till you see the ID of your current selected ProGallary.

The code above will go to the BACKEND-SECTION into your → “proGallary.jsw” -file.

b) Next step you will need to write a GALLARY BACKEND-FRONTEND-CONVERTER…

function convertToFrontend(item) {
  return {
    slug: item._id,
    type: item.type,
    src: item.image ? item.image.imageInfo : item.video.videoInfo,
    description: item.description,
    title: item.title,
    link: item.link ? item.link.url : undefined
  }
}

Without this CONVERTER-FUNCTION you will get an ERROR on FRONTEND.

c) Now use this 2 functions on your FRONTEND, sending either the ProGallary-ID directly to BACKEND, or get a list of ProGallarary-IDs on backend, sending them back to FRONTEND —> for example filling a DropDown with all existing Pro-Gallary-IDs —> giving you the possibility to CHOOSE the right ProGallay directly from a DropDown-Menu on your page.

d) Once you selected one of ProGallary-IDs —> sending it again to BACKEND.
The Backend-Functions will retrieve the correct ProGallary-Data → converting it and sending back to FRONTEND.

e) Now you have the data from your selected ProGallary inside an Object…
Which will look something like…

f) continue what to do now with all that data…

g) generate your …

search for images in Pro Gallery
…FUNCTION!!!

Very easy to do, will take you just some weeks!

!!! Good luck and happy coding !!!

!!! May the CODING POWER be with you !!!

Great post and very insightful. I will share your tips with some of our clients.