Support for AVIF

Hi there, as you may know
The new thing to the market is avif, wordpress itself can support this image and the sizing and such are available there.
But with classicpress it’s not available. any thoughts?

FYI:

<?php
/**
 * Enable AVIF types
 *
 * @see https://developer.wordpress.org/reference/functions/wp_check_filetype_and_ext/
 */
function mhmd_enable_avif_types( $types, $file, $filename, $mimes ) {
	if ( false !== strpos( $filename, '.avif' ) ) {
		$types['ext']  = 'avif';
		$types['type'] = 'image/avif';
	}

	return $types;
}
add_filter( 'wp_check_filetype_and_ext', 'mhmd_enable_avif_types', 10, 4 );

/**
 * Add mime type
 *
 * @see https://developer.wordpress.org/reference/hooks/upload_mimes/
 */
function mhmd_enable_avif_mime( $mimes ) {
	$mimes['avif'] = 'image/avif';

	return $mimes;
}
add_filter( 'upload_mimes', 'mhmd_enable_avif_mime' );

1 Like

FYI this was introduced in WordPress 6.5.

I know that my bro, that’s why I said it’s new to the market.

I think we should definitely include this in ClassicPress. If you could find the WP changeset number, that would be really helpful so that we can then backport it.

1 Like

https://core.trac.wordpress.org/changeset/57524
Here it is my dear, please note that they have a hell lot of bugs in their change sets for this new file format :smile:

https://core.trac.wordpress.org/changeset/53753

1 Like

Thanks! And thanks for the warning! If you know of other changesets that address those bugs, please add them to this thread as you find them

1 Like