Make WordPress Core


Ignore:
Timestamp:
09/19/2022 10:51:53 PM (3 years ago)
Author:
davidbaumwald
Message:

Media: Revert WebP generation.

Given Matt's recent post about removing WebP from core and possibly implementing the feature in a future Canonical Plugin, this change reverts changesets [54086], [54094], and [54097]. Additionally, [54210] contained a coding standards follow-up in one of the affected files that is no longer needed.

Reverts [54086], [54094], and [54097].

Props SergeyBiryukov.
See #55443.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor.php

    r54133 r54226  
    1616    protected $file              = null;
    1717    protected $size              = null;
    18     protected $size_name         = '';
    1918    protected $mime_type         = null;
    2019    protected $output_mime_type  = null;
     
    120119     *
    121120     * @param array $sizes {
    122      *     Associative array of image size names and their data. Default sizes are 'small', 'medium', 'large'.
     121     *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
    123122     *
    124123     *     @type array ...$0 {
     
    188187     * @since 3.5.0
    189188     *
    190      * @return array {
     189     * @return int[] {
    191190     *     Dimensions of the image.
    192191     *
     
    204203     * @since 3.5.0
    205204     *
    206      * @param int $width  The image width.
    207      * @param int $height The image height.
    208      * @return true True on success, false on failure.
     205     * @param int $width
     206     * @param int $height
     207     * @return true
    209208     */
    210209    protected function update_size( $width = null, $height = null ) {
     
    214213        );
    215214        return true;
    216     }
    217 
    218     /**
    219      * Gets the current image size name.
    220      *
    221      * @since 6.1.0
    222      *
    223      * @return string Image size name, or empty string if none set.
    224      */
    225     public function get_size_name() {
    226         return $this->size_name;
    227     }
    228 
    229     /**
    230      * Sets the current image size name.
    231      *
    232      * @since 6.1.0
    233      *
    234      * @param string $size_name The image size name.
    235      */
    236     protected function update_size_name( $size_name ) {
    237         $this->size_name = (string) $size_name;
    238215    }
    239216
     
    389366         *
    390367         * @since 5.8.0
    391          * @since 6.1.0 The $size_name parameter was added.
    392368         *
    393369         * @param string[] $output_format {
     
    399375         * @param string $filename  Path to the image.
    400376         * @param string $mime_type The source image mime type.
    401          * @param string $size_name The image size name to create, or empty string if not set.
    402377         */
    403         $output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type, $this->size_name );
     378        $output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type );
    404379
    405380        if ( isset( $output_format[ $mime_type ] )
     
    451426    }
    452427
    453         /**
    454      * Builds an output filename based on current file, and adding proper suffix.
    455      *
    456      * @since 3.5.0
    457      * @since 6.1.0 Skips adding a suffix when set to an empty string. When the
    458      *              file extension being generated doesn't match the image file extension,
    459      *              add the extension to the suffix
    460      *
    461      * @param string $suffix    Optional. Suffix to add to the filename. The default null
    462      *                          will result in a 'widthxheight' suffix. Passing
    463      *                          an empty string will result in no suffix.
    464      * @param string $dest_path Optional. The path to save the file to. The default null
    465      *                          will use the image file path.
    466      * @param string $extension Optional. The file extension to use. The default null
    467      *                          will use the image file extension.
    468      * @return string filename The generated file name.
     428    /**
     429     * Builds an output filename based on current file, and adding proper suffix
     430     *
     431     * @since 3.5.0
     432     *
     433     * @param string $suffix
     434     * @param string $dest_path
     435     * @param string $extension
     436     * @return string filename
    469437     */
    470438    public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) {
    471439        // $suffix will be appended to the destination filename, just before the extension.
    472         if ( null === $suffix ) {
     440        if ( ! $suffix ) {
    473441            $suffix = $this->get_suffix();
    474442        }
     
    491459        }
    492460
    493         if ( empty( $suffix ) ) {
    494             $suffix = '';
    495         } else {
    496             $suffix = "-{$suffix}";
    497         }
    498 
    499         // When the file extension being generated doesn't match the image file extension,
    500         // add the extension to the suffix to ensure a unique file name. Prevents
    501         // name conflicts when a single image type can have multiple extensions,
    502         // eg. .jpg, .jpeg and .jpe are all valid JPEG extensions.
    503         if ( ! empty( $extension ) && $extension !== $ext ) {
    504             $suffix .= "-{$ext}";
    505         }
    506 
    507         return trailingslashit( $dir ) . "{$name}{$suffix}.{$new_ext}";
     461        return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
    508462    }
    509463
Note: See TracChangeset for help on using the changeset viewer.