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/tests/phpunit/tests/image/editor.php

    r54085 r54086  
    1919
    2020        require_once DIR_TESTDATA . '/../includes/mock-image-editor.php';
     21        add_filter( 'image_editor_output_format', '__return_empty_array' );
    2122
    2223        // This needs to come after the mock image editor class is loaded.
    2324        parent::set_up();
     25    }
     26
     27    /**
     28     * Tear down the class.
     29     */
     30    public function tear_down() {
     31        remove_filter( 'image_editor_output_format', '__return_empty_array' );
     32        parent::tear_down();
    2433    }
    2534
     
    227236
    228237        // Test with a suffix only.
    229         $this->assertSame( 'canola-100x50.png', wp_basename( $editor->generate_filename( null, null, 'png' ) ) );
     238        $this->assertSame( 'canola-100x50-jpg.png', wp_basename( $editor->generate_filename( null, null, 'png' ) ) );
    230239
    231240        // Combo!
    232         $this->assertSame( trailingslashit( realpath( get_temp_dir() ) ) . 'canola-new.png', $editor->generate_filename( 'new', realpath( get_temp_dir() ), 'png' ) );
     241        $this->assertSame( trailingslashit( realpath( get_temp_dir() ) ) . 'canola-new-jpg.png', $editor->generate_filename( 'new', realpath( get_temp_dir() ), 'png' ) );
    233242
    234243        // Test with a stream destination.
Note: See TracChangeset for help on using the changeset viewer.