I've got a WordPress website where I need to have some posts with gifs as thumbnails. After researching this topic a bit I realized that I have to intercept the gif before it's passed into Media Gallery. I have no idea where to even begin as I haven't found any hooks to hook in.
How can I pass the gif, that's being uploaded, to a custom function? Is there a way to do it in WordPress?
put this function in ur functions.php of ur theme.
function custom_upload_filter( $file )
{
// this line catch the name of the current upload file
// and check the filetype
$filetype = wp_check_filetype($file['name']);
// then check the extension file if it isn't a gif file set the $file["error"] with an advertissement
if( $filetype["ext"] != "gif" || $filetype["ext"] != "GIF )
$file["error"] = "Please upload a file with a 'gif' extension !";
return $file;
}
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
ps: after add this functions to ur theme, u can't upload anymore other file than 'gif' file
I hope that help u.