Custom Fields and &where

Is it possible to access custom fields in a where statement?

For instance, I have a custom selectbox field on my images, and I want to be able to filter the images based on the custom field selection.

Here is my custom field for reference:

            "label":"Kitchen / Dining"
            "label":"Bathroom / Bedroom"
            "label":"Living Areas"
            "label":"Custom Homes"

I want to be able to filter the images I pull in via the snippet, so that it only pulls in condominiums for instance.

I’ve tried it a few different ways, with no results. Here’s my mgGetImages snippet. When I remove the &where statement, it works and successfully pulls in images.

[[!mgGetImages? &resource=`[[*id]]` &imageTpl=`project_gallery.tpl` &where=`{"custom.category":"condominiums"}` &sortBy=`sortorder` &sortDir=`ASC`]]

Unfortunately, no, you can’t filter on custom fields quite like that.

As an alternative solution, it’s not uncommon to see filters on top of a gallery be handled with client-side javascript where a class on a wrapper dom element are used to selectively show/hide the proper elements.

Ahh okay. That makes sense. I have a situation where I would like to pull photos from multiple resources, and I was trying to find an efficient way to only load the necessary photos, for speed.

I guess I could do a data-src and filter to only inject the source of the photos based on their custom field. Something like that could work.

Thanks for the response Mark :slight_smile: