Changeset 53845
- Timestamp:
- 08/05/2022 04:10:52 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r53843 r53845 727 727 } 728 728 729 730 /**731 * Checks if an image belongs to an attachment.732 *733 * @since 6.1.0734 * @access private735 *736 * @param string $filename Full path to the image file.737 * @param int $attachment_id Attachment ID to check.738 * @return bool True if the image belongs to the attachment, false otherwise.739 */740 function _wp_image_belongs_to_attachment( $filename, $attachment_id ) {741 $meta_data = wp_get_attachment_metadata( $attachment_id );742 743 if ( ! isset( $image_meta['sizes'] ) ) {744 return false;745 }746 $sizes = $image_meta['sizes'];747 foreach ( $sizes as $size ) {748 if ( $size['file'] === $filename ) {749 return true;750 }751 if ( isset( $size['sources'] ) && is_array( $size['sources'] ) ) {752 foreach ( $size['sources'] as $source ) {753 if ( $source['file'] === $filename ) {754 return true;755 }756 }757 }758 }759 return false;760 }761 762 729 /** 763 730 * Generates attachment meta data and create image sub-sizes for images.
Note: See TracChangeset
for help on using the changeset viewer.