Changeset 47084 for trunk/src/wp-admin/includes/image.php
- Timestamp:
- 01/18/2020 12:52:28 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/image.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r46809 r47084 25 25 function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { 26 26 $src_file = $src; 27 if ( is_numeric( $src ) ) { // Handle int as attachment ID 27 if ( is_numeric( $src ) ) { // Handle int as attachment ID. 28 28 $src_file = get_attached_file( $src ); 29 29 … … 118 118 } 119 119 120 // Remove sizes that already exist. Only checks for matching "size names". 121 // It is possible that the dimensions for a particular size name have changed. 122 // For example the user has changed the values on the Settings -> Media screen. 123 // However we keep the old sub-sizes with the previous dimensions 124 // as the image may have been used in an older post. 120 /* 121 * Remove sizes that already exist. Only checks for matching "size names". 122 * It is possible that the dimensions for a particular size name have changed. 123 * For example the user has changed the values on the Settings -> Media screen. 124 * However we keep the old sub-sizes with the previous dimensions 125 * as the image may have been used in an older post. 126 */ 125 127 $missing_sizes = array_diff_key( $possible_sizes, $image_meta['sizes'] ); 126 128 … … 230 232 } 231 233 232 // Default image meta 234 // Default image meta. 233 235 $image_meta = array( 234 236 'width' => $imagesize[0], … … 319 321 } 320 322 321 // Rotate the image 323 // Rotate the image. 322 324 $rotated = $editor->maybe_exif_rotate(); 323 325 … … 340 342 } 341 343 342 // Initial save of the new metadata. 343 // At this point the file was uploaded and moved to the uploads directory 344 // but the image sub-sizes haven't been created yet and the `sizes` array is empty. 344 /* 345 * Initial save of the new metadata. 346 * At this point the file was uploaded and moved to the uploads directory 347 * but the image sub-sizes haven't been created yet and the `sizes` array is empty. 348 */ 345 349 wp_update_attachment_metadata( $attachment_id, $image_meta ); 346 350 … … 387 391 if ( isset( $image_meta['sizes'] ) && is_array( $image_meta['sizes'] ) ) { 388 392 foreach ( $image_meta['sizes'] as $size_name => $size_meta ) { 389 // Only checks "size name" so we don't override existing images even if the dimensions 390 // don't match the currently defined size with the same name. 391 // To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta. 393 /* 394 * Only checks "size name" so we don't override existing images even if the dimensions 395 * don't match the currently defined size with the same name. 396 * To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta. 397 */ 392 398 if ( array_key_exists( $size_name, $new_sizes ) ) { 393 399 unset( $new_sizes[ $size_name ] ); … … 403 409 } 404 410 405 // Sort the image sub-sizes in order of priority when creating them. 406 // This ensures there is an appropriate sub-size the user can access immediately 407 // even when there was an error and not all sub-sizes were created. 411 /* 412 * Sort the image sub-sizes in order of priority when creating them. 413 * This ensures there is an appropriate sub-size the user can access immediately 414 * even when there was an error and not all sub-sizes were created. 415 */ 408 416 $priority = array( 409 417 'medium' => null, … … 734 742 } 735 743 736 if ( ! empty( $iptc['2#110'][0] ) ) { // credit744 if ( ! empty( $iptc['2#110'][0] ) ) { // Credit. 737 745 $meta['credit'] = trim( $iptc['2#110'][0] ); 738 } elseif ( ! empty( $iptc['2#080'][0] ) ) { // creator / legacy byline746 } elseif ( ! empty( $iptc['2#080'][0] ) ) { // Creator / legacy byline. 739 747 $meta['credit'] = trim( $iptc['2#080'][0] ); 740 748 } 741 749 742 if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // created date and time750 if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // Created date and time. 743 751 $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] ); 744 752 } 745 753 746 if ( ! empty( $iptc['2#116'][0] ) ) { // copyright754 if ( ! empty( $iptc['2#116'][0] ) ) { // Copyright. 747 755 $meta['copyright'] = trim( $iptc['2#116'][0] ); 748 756 } 749 757 750 if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array758 if ( ! empty( $iptc['2#025'][0] ) ) { // Keywords array. 751 759 $meta['keywords'] = array_values( $iptc['2#025'] ); 752 760 } … … 774 782 775 783 if ( empty( $meta['title'] ) && $description_length < 80 ) { 776 // Assume the title is stored in ImageDescription 784 // Assume the title is stored in ImageDescription. 777 785 $meta['title'] = trim( $exif['ImageDescription'] ); 778 786 }
Note: See TracChangeset
for help on using the changeset viewer.