Changeset 45934 for trunk/src/wp-admin/includes/image.php
- Timestamp:
- 09/04/2019 01:10:57 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/image.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r45871 r45934 132 132 * 133 133 * @param int $attachment_id The image attachment post ID. 134 * @return array The updated image meta data array. 134 * @return array|WP_Error The updated image meta data array or WP_Error object 135 * if both the image meta and the attached file are missing. 135 136 */ 136 137 function wp_update_image_subsizes( $attachment_id ) { 138 $image_meta = wp_get_attachment_metadata( $attachment_id ); 139 $image_file = get_attached_file( $attachment_id ); 140 141 if ( empty( $image_meta ) || ! is_array( $image_meta ) ) { 142 // Previously failed upload? 143 // If there is an uploaded file, make all sub-sizes and generate all of the attachment meta. 144 if ( ! empty( $image_file ) ) { 145 return wp_create_image_subsizes( $image_file, array(), $attachment_id ); 146 } else { 147 return new WP_Error( 'invalid_attachment', __( 'The attached file cannot be found.' ) ); 148 } 149 } 150 137 151 $missing_sizes = wp_get_missing_image_subsizes( $attachment_id ); 138 $image_meta = wp_get_attachment_metadata( $attachment_id );139 152 140 153 if ( empty( $missing_sizes ) ) { 141 154 return $image_meta; 142 155 } 143 144 $image_file = get_attached_file( $attachment_id );145 156 146 157 // This also updates the image meta.
Note: See TracChangeset
for help on using the changeset viewer.