Make WordPress Core


Ignore:
Timestamp:
09/06/2022 09:13:17 PM (2 years ago)
Author:
adamsilverstein
Message:

Media: Output WebP by default when uploading JPEGs.

Uploaded JPEGs will automatically be converted to WebP sub-sizes instead of JPEG, saving space and making sites faster.

The original JPEG upload is always retained and can be accessed by calling wp_get_original_image_url.

Props azaozz, flixos90.
Fixes #55443.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image-edit.php

    r53546 r54086  
    918918
    919919    // Save the full-size file, also needed to create sub-sizes.
    920     if ( ! wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id ) ) {
     920    $saved = wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id );
     921    if ( ! $saved ) {
    921922        $return->error = esc_js( __( 'Unable to save the image.' ) );
    922923        return $return;
    923924    }
     925    $new_path = $saved['path'];
    924926
    925927    if ( 'nothumb' === $target || 'all' === $target || 'full' === $target || $scaled ) {
Note: See TracChangeset for help on using the changeset viewer.