Make WordPress Core

Changeset 46651


Ignore:
Timestamp:
11/04/2019 05:05:53 PM (5 years ago)
Author:
azaozz
Message:

Upload: Ensure the new image meta is always saved before starting post-processing of an uploaded image, even if there was an error while scaling or rotating it.

See #48472.

File:
1 edited

Legend:

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

    r46647 r46651  
    288288                    $image_meta['image_meta']['orientation'] = 1;
    289289                }
    290 
    291                 // Initial save of the new metadata when the original image was scaled.
    292                 // At this point the file was uploaded and moved to the uploads directory
    293                 // but the image sub-sizes haven't been created yet and the `sizes` array is empty.
    294                 wp_update_attachment_metadata( $attachment_id, $image_meta );
    295290            } else {
    296291                // TODO: log errors.
     
    323318                    $image_meta['image_meta']['orientation'] = 1;
    324319                }
    325 
    326                 // Initial save of the new metadata when the original image was rotated.
    327                 wp_update_attachment_metadata( $attachment_id, $image_meta );
    328320            } else {
    329321                // TODO: log errors.
    330322            }
    331323        }
    332     } else {
    333         // Initial save of the new metadata when the image was not scaled or rotated.
    334         wp_update_attachment_metadata( $attachment_id, $image_meta );
    335     }
     324    }
     325
     326    // Initial save of the new metadata.
     327    // At this point the file was uploaded and moved to the uploads directory
     328    // but the image sub-sizes haven't been created yet and the `sizes` array is empty.
     329    wp_update_attachment_metadata( $attachment_id, $image_meta );
    336330
    337331    $new_sizes = wp_get_registered_image_subsizes();
Note: See TracChangeset for help on using the changeset viewer.