Skip to content

Instantly share code, notes, and snippets.

@giodc
Last active June 23, 2022 03:54
Show Gist options
  • Save giodc/370fa52e41968082bd604eb22e488f12 to your computer and use it in GitHub Desktop.
Save giodc/370fa52e41968082bd604eb22e488f12 to your computer and use it in GitHub Desktop.
Check if WordPress featured image is gif, and output full size image to allow animated gif in Loop
<?php
$url = wp_get_attachment_url( get_post_thumbnail_id() );
$filetype = wp_check_filetype($url);
if ($filetype[ext] == 'gif')
{the_post_thumbnail('full', array('class' => 'img-responsive')); }
else
{the_post_thumbnail('medium', array('class' => 'img-responsive'));}
?>
@lionhurt
Copy link

lionhurt commented Dec 23, 2017

Thanks for snippet but you use ext as constant it should be string:

<?php

    $url = wp_get_attachment_url( get_post_thumbnail_id() );
    $filetype = wp_check_filetype($url);

    if ($filetype['ext'] == 'gif')
    
    {the_post_thumbnail('full', array('class' => 'img-responsive')); }

    else
    {the_post_thumbnail('medium', array('class' => 'img-responsive'));}

?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment