Make WordPress Core


Ignore:
Timestamp:
10/11/2019 07:52:12 AM (5 years ago)
Author:
mikeschroder
Message:

Media: Update fallback previews to support _wp_make_subsizes()

Allows fallback previews (PDF by default, in core) to save image meta
after each size is generated to allow for resuming, and make sizes
immediately available.

Props azaozz, antpb, progremzion, mikeschroder.
See #48111.

File:
1 edited

Legend:

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

    r46421 r46459  
    582582                // Resize based on the full size image, rather than the source.
    583583                if ( ! is_wp_error( $uploaded ) ) {
    584                     $editor = wp_get_image_editor( $uploaded['path'] );
     584                    $image_file = $uploaded['path'];
    585585                    unset( $uploaded['path'] );
    586586
    587                     if ( ! is_wp_error( $editor ) ) {
    588                         $metadata['sizes']         = $editor->multi_resize( $merged_sizes );
    589                         $metadata['sizes']['full'] = $uploaded;
    590                     }
     587                    $metadata['sizes'] = array(
     588                        'full' => $uploaded,
     589                    );
     590
     591                    // Save the meta data before any image post-processing errors could happen.
     592                    wp_update_attachment_metadata( $attachment_id, $metadata );
     593
     594                    // Create sub-sizes saving the image meta after each.
     595                    $metadata = _wp_make_subsizes( $merged_sizes, $image_file, $metadata, $attachment_id );
    591596                }
    592597            }
Note: See TracChangeset for help on using the changeset viewer.