Ticket #48451: 48451.diff
File 48451.diff, 3.1 KB (added by , 5 years ago) |
---|
-
src/wp-admin/includes/image.php
282 282 if ( true === $rotated && ! empty( $image_meta['image_meta']['orientation'] ) ) { 283 283 $image_meta['image_meta']['orientation'] = 1; 284 284 } 285 286 // Initial save of the new metadata when the original image was scaled.287 // At this point the file was uploaded and moved to the uploads directory288 // but the image sub-sizes haven't been created yet and the `sizes` array is empty.289 wp_update_attachment_metadata( $attachment_id, $image_meta );290 285 } else { 291 286 // TODO: log errors. 292 287 } … … 317 312 if ( ! empty( $image_meta['image_meta']['orientation'] ) ) { 318 313 $image_meta['image_meta']['orientation'] = 1; 319 314 } 320 321 // Initial save of the new metadata when the original image was rotated.322 wp_update_attachment_metadata( $attachment_id, $image_meta );323 315 } else { 324 316 // TODO: log errors. 325 317 } 326 318 } 327 } else {328 // Initial save of the new metadata when the image was not scaled or rotated.329 wp_update_attachment_metadata( $attachment_id, $image_meta );330 319 } 331 320 321 /** 322 * Runs at interim updates to the attachment metadata. 323 * 324 * May run several times while the metadata is being created and updated. For example when creating image sub-sizes 325 * after upload, or when creating additional image sub-sizes for an existing image. 326 * 327 * @since 5.3.0 328 * 329 * @param array $image_meta The attachment metadata. 330 * @param int $attachment_id Attachment post ID. 331 */ 332 $image_meta = apply_filters( 'wp_interim_update_attachment_metadata', $image_meta, $attachment_id ); 333 334 // Initial save of the new metadata. 335 // At this point the file was uploaded and moved to the uploads directory 336 // but the image sub-sizes haven't been created yet and the `sizes` array is empty. 337 update_post_meta( $attachment_id, '_wp_attachment_metadata', $image_meta ); 338 332 339 $new_sizes = wp_get_registered_image_subsizes(); 333 340 334 341 /** … … 424 431 } else { 425 432 // Save the size meta value. 426 433 $image_meta['sizes'][ $new_size_name ] = $new_size_meta; 427 wp_update_attachment_metadata( $attachment_id, $image_meta ); 434 435 /** This filter is documented in wp-admin/includes/image.php */ 436 $image_meta = apply_filters( 'wp_interim_update_attachment_metadata', $image_meta, $attachment_id ); 437 438 // Save the updated metadata. 439 // At this point some or all of the image sub-sizes have been created. 440 update_post_meta( $attachment_id, '_wp_attachment_metadata', $image_meta ); 428 441 } 429 442 } 430 443 } else { … … 433 446 434 447 if ( ! empty( $created_sizes ) ) { 435 448 $image_meta['sizes'] = array_merge( $image_meta['sizes'], $created_sizes ); 436 wp_update_attachment_metadata( $attachment_id, $image_meta ); 449 450 /** This filter is documented in wp-admin/includes/image.php */ 451 $image_meta = apply_filters( 'wp_interim_update_attachment_metadata', $image_meta, $attachment_id ); 452 453 // Save the updated metadata. 454 update_post_meta( $attachment_id, '_wp_attachment_metadata', $image_meta ); 437 455 } 438 456 } 439 457