How to use animated GIFs in WordPress

If you want to use animated GIFs in WordPress, you may discover the animated GIF has become a static GIF. This happens because of the WordPress resizing mechanism. For each picture you upload, WordPress creates several copies in different sizes. The sizes depend on the theme and plugin settings.

Use animated GIFs with WordPress
Choose the original file size to display the animated GIF

The problem with animated GIFs is, WordPress won’t resize the animated GIF but it will take only the first frame of the file to create the resized versions. So, if you simply add a GIF via the WordPress Media Manager, you will probably grab one of the resized pictures and not the original animation. Make sure, you select the original size. In the image, you can see the select box where you choose the different sizes. If you choose “Full Size”, WordPress will take the original GIF you have uploaded before. Since WordPress hasn’t altered this image, the animation will be still working.

 

On a more technical level: Depending on which image processing is supported by the server, WordPress will choose GD Image or Imagick. The function _wp_image_editor_choose() in wp-includes/media.php selects, which program is chosen. So, WordPress will resize the picture either with the class WP_Image_Editor_Imagick or with the class WP_Image_Editor_GD, which are both extensions of WP_Image_Editor.

The following two tabs change content below.
Seine erste Webseite hat David Remer 1998 in HTML verfasst. Wenig später war er fasziniert von DHTML und JavaScript. Heute konzentriert sich vor allem auf das Entwickeln von WordPress Themes und Plugins für Inpsyde. Außerdem hat er das Buch "WordPress für Entwickler" verfasst.

Latest posts by David Remer (see all)

This post is also available in: German