Media: Revert WebP generation.

Given [https://make.wordpress.org/core/2022/09/11/webp-in-core-for-6-1/ Matt's recent post about removing WebP from core] and possibly implementing the feature in a future [https://make.wordpress.org/core/2022/09/11/canonical-plugins-revisited/ "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.
Built from https://develop.svn.wordpress.org/trunk@54226


git-svn-id: http://core.svn.wordpress.org/trunk@53785 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald
2022-09-19 22:53:10 +00:00
parent 5ec680a5a1
commit 5eb0223369
9 changed files with 31 additions and 151 deletions

View File

@@ -15,7 +15,6 @@
abstract class WP_Image_Editor {
protected $file = null;
protected $size = null;
protected $size_name = '';
protected $mime_type = null;
protected $output_mime_type = null;
protected $default_mime_type = 'image/jpeg';
@@ -119,7 +118,7 @@ abstract class WP_Image_Editor {
* @abstract
*
* @param array $sizes {
* Associative array of image size names and their data. Default sizes are 'small', 'medium', 'large'.
* An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
*
* @type array ...$0 {
* @type int $width Image width.
@@ -187,7 +186,7 @@ abstract class WP_Image_Editor {
*
* @since 3.5.0
*
* @return array {
* @return int[] {
* Dimensions of the image.
*
* @type int $width The image width.
@@ -203,9 +202,9 @@ abstract class WP_Image_Editor {
*
* @since 3.5.0
*
* @param int $width The image width.
* @param int $height The image height.
* @return true True on success, false on failure.
* @param int $width
* @param int $height
* @return true
*/
protected function update_size( $width = null, $height = null ) {
$this->size = array(
@@ -215,28 +214,6 @@ abstract class WP_Image_Editor {
return true;
}
/**
* Gets the current image size name.
*
* @since 6.1.0
*
* @return string Image size name, or empty string if none set.
*/
public function get_size_name() {
return $this->size_name;
}
/**
* Sets the current image size name.
*
* @since 6.1.0
*
* @param string $size_name The image size name.
*/
protected function update_size_name( $size_name ) {
$this->size_name = (string) $size_name;
}
/**
* Gets the Image Compression quality on a 1-100% scale.
*
@@ -388,7 +365,6 @@ abstract class WP_Image_Editor {
* @see WP_Image_Editor::get_output_format()
*
* @since 5.8.0
* @since 6.1.0 The $size_name parameter was added.
*
* @param string[] $output_format {
* An array of mime type mappings. Maps a source mime type to a new
@@ -398,9 +374,8 @@ abstract class WP_Image_Editor {
* }
* @param string $filename Path to the image.
* @param string $mime_type The source image mime type.
* @param string $size_name The image size name to create, or empty string if not set.
*/
$output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type, $this->size_name );
$output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type );
if ( isset( $output_format[ $mime_type ] )
&& $this->supports_mime_type( $output_format[ $mime_type ] )
@@ -450,26 +425,19 @@ abstract class WP_Image_Editor {
return array( $filename, $new_ext, $mime_type );
}
/**
* Builds an output filename based on current file, and adding proper suffix.
/**
* Builds an output filename based on current file, and adding proper suffix
*
* @since 3.5.0
* @since 6.1.0 Skips adding a suffix when set to an empty string. When the
* file extension being generated doesn't match the image file extension,
* add the extension to the suffix
*
* @param string $suffix Optional. Suffix to add to the filename. The default null
* will result in a 'widthxheight' suffix. Passing
* an empty string will result in no suffix.
* @param string $dest_path Optional. The path to save the file to. The default null
* will use the image file path.
* @param string $extension Optional. The file extension to use. The default null
* will use the image file extension.
* @return string filename The generated file name.
* @param string $suffix
* @param string $dest_path
* @param string $extension
* @return string filename
*/
public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) {
// $suffix will be appended to the destination filename, just before the extension.
if ( null === $suffix ) {
if ( ! $suffix ) {
$suffix = $this->get_suffix();
}
@@ -490,21 +458,7 @@ abstract class WP_Image_Editor {
}
}
if ( empty( $suffix ) ) {
$suffix = '';
} else {
$suffix = "-{$suffix}";
}
// When the file extension being generated doesn't match the image file extension,
// add the extension to the suffix to ensure a unique file name. Prevents
// name conflicts when a single image type can have multiple extensions,
// eg. .jpg, .jpeg and .jpe are all valid JPEG extensions.
if ( ! empty( $extension ) && $extension !== $ext ) {
$suffix .= "-{$ext}";
}
return trailingslashit( $dir ) . "{$name}{$suffix}.{$new_ext}";
return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
}
/**