Changeset 57524 for trunk/src/wp-includes/class-wp-image-editor-gd.php
- Timestamp:
- 02/02/2024 05:46:50 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-image-editor-gd.php
r56418 r57524 72 72 case 'image/webp': 73 73 return ( $image_types & IMG_WEBP ) != 0; 74 case 'image/avif': 75 return ( $image_types & IMG_AVIF ) != 0; 74 76 } 75 77 … … 112 114 } 113 115 116 // AVIF may not work with imagecreatefromstring(). 117 if ( 118 function_exists( 'imagecreatefromavif' ) && 119 ( 'image/avif' === wp_get_image_mime( $this->file ) ) 120 ) { 121 $this->image = @imagecreatefromavif( $this->file ); 122 } else { 123 $this->image = @imagecreatefromstring( $file_contents ); 124 } 125 114 126 if ( ! is_gd_image( $this->image ) ) { 115 127 return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file ); … … 512 524 } elseif ( 'image/webp' == $mime_type ) { 513 525 if ( ! function_exists( 'imagewebp' ) || ! $this->make_image( $filename, 'imagewebp', array( $image, $filename, $this->get_quality() ) ) ) { 526 return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); 527 } 528 } elseif ( 'image/avif' == $mime_type ) { 529 if ( ! function_exists( 'imageavif' ) || ! $this->make_image( $filename, 'imageavif', array( $image, $filename, $this->get_quality() ) ) ) { 514 530 return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); 515 531 } … … 562 578 header( 'Content-Type: image/webp' ); 563 579 return imagewebp( $this->image, null, $this->get_quality() ); 580 } else { 581 // Fall back to JPEG. 582 header( 'Content-Type: image/jpeg' ); 583 return imagejpeg( $this->image, null, $this->get_quality() ); 564 584 } 565 // Fall back to the default if webp isn't supported. 585 case 'image/avif': 586 if ( function_exists( 'imageavif' ) ) { 587 header( 'Content-Type: image/avif' ); 588 return imageavif( $this->image, null, $this->get_quality() ); 589 } 590 // Fall back to JPEG. 566 591 default: 567 592 header( 'Content-Type: image/jpeg' );
Note: See TracChangeset
for help on using the changeset viewer.