WordPress.org

Make WordPress Core

Ticket #38594: 38594.diff

File 38594.diff, 1.0 KB (added by joemcgill, 4 years ago)
  • src/wp-admin/includes/image.php

    diff --git src/wp-admin/includes/image.php src/wp-admin/includes/image.php
    index 87b8191..c21aa16 100644
    function wp_generate_attachment_metadata( $attachment_id, $file ) { 
    213213                        'large',
    214214                );
    215215
     216                /**
     217                 * Filters the image sizes generated for non-image mime types.
     218                 *
     219                 * @since 4.7.0
     220                 *
     221                 * @param array $fallback_sizes An array of image size names.
     222                 */
     223                $fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata );
     224
    216225                $sizes = array();
    217226
    218227                foreach ( $fallback_sizes as $s ) {
    function wp_generate_attachment_metadata( $attachment_id, $file ) { 
    234243                                $editor = wp_get_image_editor( $uploaded['path'] );
    235244                                unset( $uploaded['path'] );
    236245
    237                                 if ( ! is_wp_error( $editor ) ) {
     246                                if ( ! is_wp_error( $editor ) && ! empty( $fallback_sizes ) ) {
    238247                                        $metadata['sizes'] = $editor->multi_resize( $sizes );
    239248                                        $metadata['sizes']['full'] = $uploaded;
    240249                                }