diff --git src/wp-includes/media.php src/wp-includes/media.php
index 0ba67a9..87af0dd 100644
|
|
|
function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa |
| 813 | 813 | |
| 814 | 814 | // Generate 'srcset' and 'sizes' if not already present. |
| 815 | 815 | if ( empty( $attr['srcset'] ) ) { |
| 816 | | $image_meta = wp_get_attachment_metadata( $attachment_id ); |
| | 816 | $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); |
| 817 | 817 | |
| 818 | 818 | if ( is_array( $image_meta ) ) { |
| 819 | 819 | $size_array = array( absint( $width ), absint( $height ) ); |
| 820 | 820 | $srcset = wp_calculate_image_srcset( $src, $size_array, $image_meta, $attachment_id ); |
| 821 | | $sizes = wp_get_attachment_image_sizes( $size_array, $image_meta, $attachment_id ); |
| | 821 | $sizes = wp_get_attachment_image_sizes( $size_array, $image_meta, $attachment_id, $src ); |
| 822 | 822 | |
| 823 | 823 | if ( $srcset && ( $sizes || ! empty( $attr['sizes'] ) ) ) { |
| 824 | 824 | $attr['srcset'] = $srcset; |
| … |
… |
function wp_calculate_image_srcset( $image_name, $size_array, $image_meta, $atta |
| 1082 | 1082 | * @param array $image_meta Optional. The image meta data as returned by 'wp_get_attachment_metadata()'. |
| 1083 | 1083 | * @param int $attachment_id Optional. Image attachment ID. Either `$image_meta` or `$attachment_id` is needed |
| 1084 | 1084 | * when using the image size name as argument for `$size`. |
| | 1085 | * @param string $image_url Optional. The URL to the image file. |
| 1085 | 1086 | * |
| 1086 | 1087 | * @return string|bool A valid source size value for use in a 'sizes' attribute or false. |
| 1087 | 1088 | */ |
| 1088 | | function wp_get_attachment_image_sizes( $size, $image_meta = null, $attachment_id = 0 ) { |
| | 1089 | function wp_get_attachment_image_sizes( $size, $image_meta = null, $attachment_id = 0, $image_url = null ) { |
| 1089 | 1090 | $width = 0; |
| 1090 | 1091 | |
| 1091 | 1092 | if ( is_numeric( $size ) ) { |
| … |
… |
function wp_get_attachment_image_sizes( $size, $image_meta = null, $attachment_i |
| 1122 | 1123 | * values in pixels (in that order). |
| 1123 | 1124 | * @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'. |
| 1124 | 1125 | * @param int $attachment_id Image attachment ID of the original image. |
| | 1126 | * @param string $image_url Optional. The URL to the image file. |
| 1125 | 1127 | */ |
| 1126 | | return apply_filters( 'wp_get_attachment_image_sizes', $sizes, $size, $image_meta, $attachment_id ); |
| | 1128 | return apply_filters( 'wp_get_attachment_image_sizes', $sizes, $size, $image_meta, $attachment_id, $image_url ); |
| 1127 | 1129 | } |
| 1128 | 1130 | |
| 1129 | 1131 | /** |
| … |
… |
function wp_image_add_srcset_and_sizes( $image, $image_meta, $attachment_id ) { |
| 1239 | 1241 | $srcset = wp_calculate_image_srcset( $src, $size_array, $image_meta, $attachment_id ); |
| 1240 | 1242 | |
| 1241 | 1243 | if ( $srcset ) { |
| 1242 | | $sizes = wp_get_attachment_image_sizes( $size_array, $image_meta, $attachment_id ); |
| | 1244 | $sizes = wp_get_attachment_image_sizes( $size_array, $image_meta, $attachment_id, $src ); |
| 1243 | 1245 | } |
| 1244 | 1246 | |
| 1245 | 1247 | if ( $srcset && $sizes ) { |