How to generate customized filtered output for the gallery

How to generate customized filtered output for the gallery