How to select just gif from pages media

Please be advised that gifs are not ‘images’ but instead ‘animated images’. See Supported Media Files and class AbstractMedia which is returned by page.media in Twig.

This means that the array returned by page.media.images does not contain gif files.

One could get access to all media types included the gifs by using:

  • page.media['my-animated.gif']
  • page.media.files, or page.media.all and filter the resulting array on gif extension

The rationale of gifs being excluded from page.media.images is that the image manipulation functions do not work properly on gifs. See this issue at Github.

Just for completeness, a similar discussion on gifs can be found in thread Animated GIFs not showing at Quark blog list page

Hope this clarifies the issue of gifs a bit…