Been looking for a way to do this but cant seem to find anything, not even here.
I am using timthumb to re-size my sites images. As most of you know after re-sizing a animated gif its not going to work any more. So i need a way to skip over the image if its a .gif file type. Something like
<?php if( typegif() ) { ?>
<img src="<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'full' ); echo $src[0]; ?>" alt="Image# <?php the_ID(); ?> "/>
<?php } else { ?>
<img src="<?php bloginfo( 'template_url' ); ?>/thumbs/timthumb.php?src=<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); echo $src[0]; ?>&w=280" alt="Image# <?php the_ID(); ?> "/>
<?php } ?>
After some more digging i found this code, however its not working.
$attachment_mime = wp_check_filetype(wp_get_attachment_url($post->ID) );
if ( $attachment_mime['type'] == 'image/gif') {
echo 'this is gif';
}
else {
echo 'this aint gif';
}
I’m not quite sure you’re using the
wp_check_filetype()
correctly. I just successfully tried the following to determine if the post thumbnail ext was jpg or not:You probably know already but if you ever want to see what the function returns, you can use
echo print_r($filetype)
and it will print the returned array and you can dissect how to best use the returned information (sometimes easier than interpreting up the codex!)