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. git-svn-id: https://develop.svn.wordpress.org/trunk@46459 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
466937669a
commit
68729adb57
@ -581,13 +581,18 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||||||
|
|
||||||
// Resize based on the full size image, rather than the source.
|
// Resize based on the full size image, rather than the source.
|
||||||
if ( ! is_wp_error( $uploaded ) ) {
|
if ( ! is_wp_error( $uploaded ) ) {
|
||||||
$editor = wp_get_image_editor( $uploaded['path'] );
|
$image_file = $uploaded['path'];
|
||||||
unset( $uploaded['path'] );
|
unset( $uploaded['path'] );
|
||||||
|
|
||||||
if ( ! is_wp_error( $editor ) ) {
|
$metadata['sizes'] = array(
|
||||||
$metadata['sizes'] = $editor->multi_resize( $merged_sizes );
|
'full' => $uploaded,
|
||||||
$metadata['sizes']['full'] = $uploaded;
|
);
|
||||||
}
|
|
||||||
|
// Save the meta data before any image post-processing errors could happen.
|
||||||
|
wp_update_attachment_metadata( $attachment_id, $metadata );
|
||||||
|
|
||||||
|
// Create sub-sizes saving the image meta after each.
|
||||||
|
$metadata = _wp_make_subsizes( $merged_sizes, $image_file, $metadata, $attachment_id );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,10 +435,10 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'sizes' => array(
|
'sizes' => array(
|
||||||
'thumbnail' => array(
|
'full' => array(
|
||||||
'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg',
|
'file' => 'wordpress-gsoc-flyer-pdf.jpg',
|
||||||
'width' => 116,
|
'width' => 1088,
|
||||||
'height' => 150,
|
'height' => 1408,
|
||||||
'mime-type' => 'image/jpeg',
|
'mime-type' => 'image/jpeg',
|
||||||
),
|
),
|
||||||
'medium' => array(
|
'medium' => array(
|
||||||
@ -453,10 +453,10 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||||||
'height' => 1024,
|
'height' => 1024,
|
||||||
'mime-type' => 'image/jpeg',
|
'mime-type' => 'image/jpeg',
|
||||||
),
|
),
|
||||||
'full' => array(
|
'thumbnail' => array(
|
||||||
'file' => 'wordpress-gsoc-flyer-pdf.jpg',
|
'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg',
|
||||||
'width' => 1088,
|
'width' => 116,
|
||||||
'height' => 1408,
|
'height' => 150,
|
||||||
'mime-type' => 'image/jpeg',
|
'mime-type' => 'image/jpeg',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -500,10 +500,10 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'sizes' => array(
|
'sizes' => array(
|
||||||
'thumbnail' => array(
|
'full' => array(
|
||||||
'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg',
|
'file' => 'wordpress-gsoc-flyer-pdf.jpg',
|
||||||
'width' => 116,
|
'width' => 1088,
|
||||||
'height' => 150,
|
'height' => 1408,
|
||||||
'mime-type' => 'image/jpeg',
|
'mime-type' => 'image/jpeg',
|
||||||
),
|
),
|
||||||
'medium' => array(
|
'medium' => array(
|
||||||
@ -518,10 +518,10 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||||||
'height' => 1024,
|
'height' => 1024,
|
||||||
'mime-type' => 'image/jpeg',
|
'mime-type' => 'image/jpeg',
|
||||||
),
|
),
|
||||||
'full' => array(
|
'thumbnail' => array(
|
||||||
'file' => 'wordpress-gsoc-flyer-pdf.jpg',
|
'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg',
|
||||||
'width' => 1088,
|
'width' => 116,
|
||||||
'height' => 1408,
|
'height' => 150,
|
||||||
'mime-type' => 'image/jpeg',
|
'mime-type' => 'image/jpeg',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user