Changeset 62176
- Timestamp:
- 03/30/2026 12:16:18 AM (7 days ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/embed.php
r61649 r62176 740 740 741 741 if ( $thumbnail_id ) { 742 list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 0 ) ); 743 $data['thumbnail_url'] = $thumbnail_url; 744 $data['thumbnail_width'] = $thumbnail_width; 745 $data['thumbnail_height'] = $thumbnail_height; 742 $thumbnail_src = wp_get_attachment_image_src( $thumbnail_id, array( $width, 0 ) ); 743 744 if ( is_array( $thumbnail_src ) ) { 745 $data['thumbnail_url'] = $thumbnail_src[0]; 746 $data['thumbnail_width'] = $thumbnail_src[1]; 747 $data['thumbnail_height'] = $thumbnail_src[2]; 748 } 746 749 } 747 750 -
trunk/src/wp-includes/media.php
r62081 r62176 973 973 * @type bool $3 Whether the image is a resized image. 974 974 * } 975 * @phpstan-return array{ 0: string, 1: int, 2: int, 3: bool }|false 975 976 */ 976 977 function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) { … … 978 979 $image = image_downsize( $attachment_id, $size ); 979 980 if ( ! $image ) { 980 $src = false; 981 $src = false; 982 $width = 0; 983 $height = 0; 981 984 982 985 if ( $icon ) { … … 989 992 $src_file = $icon_dir . '/' . wp_basename( $src ); 990 993 991 list( $width, $height ) = wp_getimagesize( $src_file ); 994 $image_size = wp_getimagesize( $src_file ); 995 if ( is_array( $image_size ) ) { 996 $width = $image_size[0]; 997 $height = $image_size[1]; 998 } 992 999 993 1000 $ext = strtolower( substr( $src_file, -4 ) ); … … 998 1005 $height = 64; 999 1006 } else { 1000 list( $width, $height ) = wp_getimagesize( $src_file ); 1007 $image_size = wp_getimagesize( $src_file ); 1008 if ( is_array( $image_size ) ) { 1009 $width = $image_size[0]; 1010 $height = $image_size[1]; 1011 } 1001 1012 } 1002 1013 } … … 1025 1036 * @param bool $icon Whether the image should be treated as an icon. 1026 1037 */ 1027 return apply_filters( 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ); 1038 $source = apply_filters( 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ); 1039 if ( is_array( $source ) && isset( $source[0] ) && is_string( $source[0] ) ) { 1040 return array( 1041 $source[0], 1042 (int) ( $source[1] ?? 0 ), 1043 (int) ( $source[2] ?? 0 ), 1044 (bool) ( $source[3] ?? false ), 1045 ); 1046 } 1047 return false; 1028 1048 } 1029 1049 … … 3231 3251 $thumb_id = get_post_thumbnail_id( $attachment->ID ); 3232 3252 if ( ! empty( $thumb_id ) ) { 3233 list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' ); 3234 $track['image'] = compact( 'src', 'width', 'height' ); 3235 list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' ); 3236 $track['thumb'] = compact( 'src', 'width', 'height' ); 3253 $image_src_full = wp_get_attachment_image_src( $thumb_id, 'full' ); 3254 if ( is_array( $image_src_full ) ) { 3255 $track['image'] = array( 3256 'src' => $image_src_full[0], 3257 'width' => $image_src_full[1], 3258 'height' => $image_src_full[2], 3259 ); 3260 } 3261 3262 $image_src_thumb = wp_get_attachment_image_src( $thumb_id, 'thumbnail' ); 3263 if ( is_array( $image_src_thumb ) ) { 3264 $track['thumb'] = array( 3265 'src' => $image_src_thumb[0], 3266 'width' => $image_src_thumb[1], 3267 'height' => $image_src_thumb[2], 3268 ); 3269 } 3237 3270 } else { 3238 3271 $src = wp_mime_type_icon( $attachment->ID, '.svg' ); … … 4712 4745 $id = get_post_thumbnail_id( $attachment->ID ); 4713 4746 if ( ! empty( $id ) ) { 4714 list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'full' ); 4715 $response['image'] = compact( 'src', 'width', 'height' ); 4716 list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'thumbnail' ); 4717 $response['thumb'] = compact( 'src', 'width', 'height' ); 4747 $response_image_full = wp_get_attachment_image_src( $id, 'full' ); 4748 if ( is_array( $response_image_full ) ) { 4749 $response['image'] = array( 4750 'src' => $response_image_full[0], 4751 'width' => $response_image_full[1], 4752 'height' => $response_image_full[2], 4753 ); 4754 } 4755 4756 $response_image_thumb = wp_get_attachment_image_src( $id, 'thumbnail' ); 4757 if ( is_array( $response_image_thumb ) ) { 4758 $response['thumb'] = array( 4759 'src' => $response_image_thumb[0], 4760 'width' => $response_image_thumb[1], 4761 'height' => $response_image_thumb[2], 4762 ); 4763 } 4718 4764 } else { 4719 4765 $src = wp_mime_type_icon( $attachment->ID, '.svg' ); … … 5725 5771 * @param array $image_info Optional. Extended image information (passed by reference). 5726 5772 * @return array|false Array of image information or false on failure. 5773 * @phpstan-return array{ 0: int, 1: int, 2: int, 3: string, mime: string, bits?: int, channels?: int }|false 5727 5774 */ 5728 5775 function wp_getimagesize( $filename, ?array &$image_info = null ) {
Note: See TracChangeset
for help on using the changeset viewer.