How can I only show images, videos, or PDFs?

If your galleries contain different types of media, but you want to show different types separately or only include some in a lightbox solution, you can filter the mgGetImages snippet on the type of media. 

This uses the &where conditional property to apply an extra condition to the SQL query to retrieve records.

For example, to render only images:

[[!mgGetImages? &where=`{"class_key":"mgImage"}`]]

To render only video:

[[!mgGetImages? &where=`{"class_key:IN":["mgYouTubeVideo","mgVimeoVideo"]}`]]

To render only PDF documents:

[[!mgGetImages? &where=`{"extension":"pdf"}`]]

Do note that not all fields on the database tables are indexed, the extension is an example of a field that is not optimized for filtering on. On large galleries (hundreds/thousands of images) that may cause processing delays for the first uncached lookup.

Still need help? Send us an email Send us an email