Code Duplication    Length = 17-17 lines in 2 locations

src/wp-includes/media.php 2 locations

@@ 987-1003 (lines=17) @@
984
 *                                    Default null.
985
 * @return string|bool A 'srcset' value string or false.
986
 */
987
function wp_get_attachment_image_srcset( $attachment_id, $size = 'medium', $image_meta = null ) {
988
	if ( ! $image = wp_get_attachment_image_src( $attachment_id, $size ) ) {
989
		return false;
990
	}
991
992
	if ( ! is_array( $image_meta ) ) {
993
		$image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
994
	}
995
996
	$image_src = $image[0];
997
	$size_array = array(
998
		absint( $image[1] ),
999
		absint( $image[2] )
1000
	);
1001
1002
	return wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attachment_id );
1003
}
1004
1005
/**
1006
 * A helper function to calculate the image sources to include in a 'srcset' attribute.
@@ 1203-1219 (lines=17) @@
1200
 *                                    Default null.
1201
 * @return string|bool A valid source size value for use in a 'sizes' attribute or false.
1202
 */
1203
function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $image_meta = null ) {
1204
	if ( ! $image = wp_get_attachment_image_src( $attachment_id, $size ) ) {
1205
		return false;
1206
	}
1207
1208
	if ( ! is_array( $image_meta ) ) {
1209
		$image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
1210
	}
1211
1212
	$image_src = $image[0];
1213
	$size_array = array(
1214
		absint( $image[1] ),
1215
		absint( $image[2] )
1216
	);
1217
1218
	return wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id );
1219
}
1220
1221
/**
1222
 * Creates a 'sizes' attribute value for an image.