Check if WordPress featured image is gif, and output full size image to allow animated gif in Loop

You already know that animated gif in WordPress are also resized to media sizes, so, if your theme do not use “full” featured image size in template, the animated gif will not display correctly.
you can use this code in WordPress loop, to check if the image is a gif, and output in full size that retain the animations frame of the image. Be careful on sizes of .gif files, because it output in full resolution can be slow-down your site.

    $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')); }
    {the_post_thumbnail('medium', array('class' => 'img-responsive'));}