Make WordPress Core


Ignore:
Timestamp:
09/06/2022 09:11:41 PM (4 years ago)
Author:
adamsilverstein
Message:

Media: revert the multi-mime feature.

This feature isn't quite ready to land.

Reverts r53786, r53848, r53847, r53845, r53751.

Props flixos90, azaozz, dd32.
See #55443.

File:
1 edited

Legend:

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

    r53751 r54085  
    334334    protected function get_output_format( $filename = null, $mime_type = null ) {
    335335        $new_ext = null;
    336 
    337         // If no mime type is passed but output mime type is set, use that.
    338         if ( ! $mime_type && ! empty( $this->output_mime_type ) ) {
    339             $mime_type = $this->output_mime_type;
    340         }
    341336
    342337        // By default, assume specified type takes priority.
     
    431426
    432427    /**
    433      * Builds an output filename based on current file, and adding proper suffix.
    434      *
    435      * @since 3.5.0
    436      * @since 6.1.0 Skips adding a suffix when set to an empty string. When the
    437      *              file extension being generated doesn't match the image file extension,
    438      *              add the extension to the suffix
    439      *
    440      * @param string $suffix    Optional. Suffix to add to the filename. The default null
    441      *                          will result in a 'widthxheight' suffix. Passing
    442      *                          an empty string will result in no suffix.
    443      * @param string $dest_path Optional. The path to save the file to. The default null
    444      *                          will use the image file path.
    445      * @param string $extension Optional. The file extension to use. The default null
    446      *                          will use the image file extension.
    447      * @return string filename The generated file name.
     428     * Builds an output filename based on current file, and adding proper suffix
     429     *
     430     * @since 3.5.0
     431     *
     432     * @param string $suffix
     433     * @param string $dest_path
     434     * @param string $extension
     435     * @return string filename
    448436     */
    449437    public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) {
    450438        // $suffix will be appended to the destination filename, just before the extension.
    451         if ( null === $suffix ) {
     439        if ( ! $suffix ) {
    452440            $suffix = $this->get_suffix();
    453441        }
     
    470458        }
    471459
    472         if ( empty( $suffix ) ) {
    473             $suffix = '';
    474         } else {
    475             $suffix = "-{$suffix}";
    476         }
    477 
    478         // When the file extension being generated doesn't match the image file extension,
    479         // add the extension to the suffix to ensure a unique file name. Prevents
    480         // name conflicts when a single image type can have multiple extensions,
    481         // eg. .jpg, .jpeg and .jpe are all valid JPEG extensions.
    482         if ( ! empty( $extension ) && $extension !== $ext ) {
    483             $suffix .= "-{$ext}";
    484         }
    485 
    486         return trailingslashit( $dir ) . "{$name}{$suffix}.{$new_ext}";
     460        return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
    487461    }
    488462
     
    664638        return wp_get_default_extension_for_mime_type( $mime_type );
    665639    }
    666 
    667     /**
    668      * Set the editor output mime type, useful when outputting alternate mime types.
    669      *
    670      * Track that the mime type is set with the mime type set flag.
    671      *
    672      * @since 6.1.0
    673      *
    674      * @param string $output_mime_type The mime type to set.
    675      */
    676     public function set_output_mime_type( $output_mime_type ) {
    677         $this->output_mime_type = $output_mime_type;
    678     }
    679 
    680     /**
    681      * Reset the mime type to the original file mime type.
    682      *
    683      * Reset the mime type set flag.
    684      *
    685      * @since 6.1.0
    686      */
    687     public function reset_output_mime_type() {
    688         $this->output_mime_type = $this->mime_type;
    689     }
    690640}
     641
Note: See TracChangeset for help on using the changeset viewer.