[wp-trac] [WordPress Trac] #60910: WP 6.5: the code add support for AVIF image files in WordPress not work now

WordPress Trac noreply at wordpress.org
Wed Apr 3 17:30:46 UTC 2024


#60910: WP 6.5: the code add support for AVIF image files in WordPress not work now
--------------------------+-------------------------------------------
 Reporter:  niktat        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  assigned
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Formatting    |    Version:  6.5
 Severity:  normal        |   Keywords:  changes-requested needs-patch
  Focuses:                |
--------------------------+-------------------------------------------
 Using AVIF images in WordPress even after adding code that supports AVIF
 image files in WordPress by adding the AVIF and AVIFS MIME types to the
 function.php file is not currently possible. This was possible in previous
 versions.

 You wrote: AVIF images work like any other image format in WordPress, with
 a few important notes:
 AVIF in WordPress depends on support in your web server’s image processing
 library (WordPress has built-in support for both Imagick and LibGD for
 image processing). You can check for AVIF support in wp-admin by visiting
 Tools -> Site Health, clicking the “Info” tab and expanding the “Media
 Handling” section, then finally looking for “AVIF” in the list of
 supported formats.

 AVIF is absent there.

 Please fix it!

 FOR your information:
 function add_avif_to_upload_mimes($mime_types) {
     $mime_types['avif'] = 'image/avif';
     $mime_types['avifs'] = 'image/avif-sequence';
     return $mime_types;
 }

 add_filter('upload_mimes', 'add_avif_to_upload_mimes');

 // Enable preview / thumbnail for avif image files.
 function avif_is_displayable($result, $path) {
     if ($result === false) {
         $displayable_image_types = array( IMAGETYPE_JPC, IMAGETYPE_JP2,
 IMAGETYPE_JPX );
         $info = @getimagesize( $path );
         if (empty($info)) {
             $result = false;
         } elseif (!in_array($info[2], $displayable_image_types)) {
             $result = false;
         } else {
             $result = true;
         }
     }
     return $result;
 }
 add_filter('file_is_displayable_image', 'avif_is_displayable', 10, 2);

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60910>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list