diff --git src/wp-includes/media.php src/wp-includes/media.php
index 79fb36e..bba996f 100644
|
|
function _wp_get_image_size_from_meta( $size_name, $image_meta ) { |
930 | 930 | * |
931 | 931 | * @since 4.4.0 |
932 | 932 | * |
933 | | * @param int $attachment_id Optional. Image attachment ID. |
| 933 | * @param int $attachment_id Image attachment ID. |
934 | 934 | * @param array|string $size Image size. Accepts any valid image size, or an array of width and height |
935 | 935 | * values in pixels (in that order). Default 'medium'. |
936 | 936 | * @param array $image_meta Optional. The image meta data as returned by 'wp_get_attachment_metadata()'. |
… |
… |
function wp_get_attachment_image_srcset( $attachment_id, $size = 'medium', $imag |
941 | 941 | return false; |
942 | 942 | } |
943 | 943 | |
944 | | if ( ! is_array( $image_meta ) ) { |
945 | | $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); |
946 | | } |
947 | | |
948 | 944 | $image_url = $image[0]; |
949 | 945 | $size_array = array( |
950 | 946 | absint( $image[1] ), |
951 | 947 | absint( $image[2] ) |
952 | 948 | ); |
953 | 949 | |
| 950 | if ( empty( $image_meta['sizes'] ) ) { |
| 951 | $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); |
| 952 | |
| 953 | if ( ! is_array( $image_meta ) ) { |
| 954 | return false; |
| 955 | } |
| 956 | } |
| 957 | |
954 | 958 | return wp_calculate_image_srcset( $image_url, $size_array, $image_meta, $attachment_id ); |
955 | 959 | } |
956 | 960 | |
… |
… |
function wp_calculate_image_srcset( $image_name, $size_array, $image_meta, $atta |
1059 | 1063 | * |
1060 | 1064 | * @since 4.4.0 |
1061 | 1065 | * |
1062 | | * @param array $sources An array of image URLs and widths. |
| 1066 | * @param array $sources An array of sources to include in the 'srcset'. Each source |
| 1067 | * consists of an array containing the URL and the descriptor |
| 1068 | * type and value (default: the image width): |
| 1069 | * |
| 1070 | * image width => array( |
| 1071 | * 'url' => string, |
| 1072 | * 'descriptor' => string ('w' or 'x'), |
| 1073 | * 'value' => integer (width or pixel density) |
| 1074 | * }, |
| 1075 | * |
1063 | 1076 | * @param int $attachment_id Image attachment ID. |
1064 | 1077 | * @param array $size_array Array of width and height values in pixels (in that order). |
1065 | 1078 | * @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'. |
… |
… |
function wp_calculate_image_srcset( $image_name, $size_array, $image_meta, $atta |
1098 | 1111 | function wp_get_attachment_image_sizes( $size, $image_meta = null, $attachment_id = 0, $image_url = null ) { |
1099 | 1112 | $width = 0; |
1100 | 1113 | |
1101 | | if ( is_numeric( $size ) ) { |
1102 | | $width = absint( $size ); |
1103 | | } elseif ( is_array( $size ) ) { |
| 1114 | if ( is_array( $size ) ) { |
1104 | 1115 | $width = absint( $size[0] ); |
1105 | 1116 | } elseif ( is_string( $size ) ) { |
1106 | 1117 | if ( ! $image_meta && $attachment_id ) { |
1107 | | $image_meta = wp_get_attachment_metadata( $attachment_id ); |
| 1118 | $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); |
1108 | 1119 | } |
1109 | 1120 | |
1110 | 1121 | if ( is_array( $image_meta ) ) { |