Code Duplication    Length = 17-17 lines in 2 locations

wp-includes/media.php 2 locations

@@ 1003-1019 (lines=17) @@
1000
 *                                    Default null.
1001
 * @return string|bool A 'srcset' value string or false.
1002
 */
1003
function wp_get_attachment_image_srcset( $attachment_id, $size = 'medium', $image_meta = null ) {
1004
	if ( ! $image = wp_get_attachment_image_src( $attachment_id, $size ) ) {
1005
		return false;
1006
	}
1007
1008
	if ( ! is_array( $image_meta ) ) {
1009
		$image_meta = wp_get_attachment_metadata( $attachment_id );
1010
	}
1011
1012
	$image_src = $image[0];
1013
	$size_array = array(
1014
		absint( $image[1] ),
1015
		absint( $image[2] )
1016
	);
1017
1018
	return wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attachment_id );
1019
}
1020
1021
/**
1022
 * A helper function to calculate the image sources to include in a 'srcset' attribute.
@@ 1219-1235 (lines=17) @@
1216
 *                                    Default null.
1217
 * @return string|bool A valid source size value for use in a 'sizes' attribute or false.
1218
 */
1219
function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $image_meta = null ) {
1220
	if ( ! $image = wp_get_attachment_image_src( $attachment_id, $size ) ) {
1221
		return false;
1222
	}
1223
1224
	if ( ! is_array( $image_meta ) ) {
1225
		$image_meta = wp_get_attachment_metadata( $attachment_id );
1226
	}
1227
1228
	$image_src = $image[0];
1229
	$size_array = array(
1230
		absint( $image[1] ),
1231
		absint( $image[2] )
1232
	);
1233
1234
	return wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id );
1235
}
1236
1237
/**
1238
 * Creates a 'sizes' attribute value for an image.