This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Questions Regarding CSS Handling and Few Other Things

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Questions Regarding CSS Handling and Few Other Things Reply To: Questions Regarding CSS Handling and Few Other Things

#26589
Michael SamsonMichael Samson
Participant

Hi Ernest,

Please read my above post first… 😉

I just wanted to tell you that I successfully disabled image resizing for gif files with the code below. This code works, and I have tested it with ASP. I can confirm that the gif animation now works in ASP when rolling over the search result (card). Very cool feature btw!

Apparently this is a very old problem in WordPress that is currently being worked on. There’s more than one trac ticket for it. But it seems like it isn’t fully solved yet from what I read. It made more sense to just disabled image sizes for gifs, since they’re almost always animated anyway.

Here’s the code I used to do this in case you’re interested, or anyone else needs it:

function disable_image_sizes_for_gif_files( $sizes, $metadata ) {
	// Get filetype data
	$filetype = wp_check_filetype($metadata['file']);
	// Check if file is gif
	if($filetype['type'] == 'image/gif') {
		// Unset sizes if file is gif
		$sizes = array();
	}
	// Return sizes you want to create from image (none if image is gif)
	return $sizes;
}

add_filter( 'intermediate_image_sizes_advanced', 'disable_image_sizes_for_gif_files', 10, 2 );

All my best,

~ Michael