Changeset 54226 for trunk/src/wp-includes/class-wp-image-editor.php
- Timestamp:
- 09/19/2022 10:51:53 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-image-editor.php
r54133 r54226 16 16 protected $file = null; 17 17 protected $size = null; 18 protected $size_name = '';19 18 protected $mime_type = null; 20 19 protected $output_mime_type = null; … … 120 119 * 121 120 * @param array $sizes { 122 * A ssociative 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'. 123 122 * 124 123 * @type array ...$0 { … … 188 187 * @since 3.5.0 189 188 * 190 * @return array{189 * @return int[] { 191 190 * Dimensions of the image. 192 191 * … … 204 203 * @since 3.5.0 205 204 * 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 209 208 */ 210 209 protected function update_size( $width = null, $height = null ) { … … 214 213 ); 215 214 return true; 216 }217 218 /**219 * Gets the current image size name.220 *221 * @since 6.1.0222 *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.0233 *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;238 215 } 239 216 … … 389 366 * 390 367 * @since 5.8.0 391 * @since 6.1.0 The $size_name parameter was added.392 368 * 393 369 * @param string[] $output_format { … … 399 375 * @param string $filename Path to the image. 400 376 * @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.402 377 */ 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 ); 404 379 405 380 if ( isset( $output_format[ $mime_type ] ) … … 451 426 } 452 427 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 469 437 */ 470 438 public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) { 471 439 // $suffix will be appended to the destination filename, just before the extension. 472 if ( null ===$suffix ) {440 if ( ! $suffix ) { 473 441 $suffix = $this->get_suffix(); 474 442 } … … 491 459 } 492 460 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}"; 508 462 } 509 463
Note: See TracChangeset
for help on using the changeset viewer.