wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_get_attachment_image_sizes › WordPress Function

Od4.4.0
Przestarzałyn/a
wp_get_attachment_image_sizes ( $attachment_id, $size = 'medium', $image_meta = null )
Parametry: (3)
  • (int) $attachment_id Image attachment ID.
    Wymagane: Tak
  • (string|int[]) $size Optional. Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default 'medium'.
    Wymagane: Nie
    Domyślny: 'medium'
  • (array|null) $image_meta Optional. The image meta data as returned by 'wp_get_attachment_metadata()'. Default null.
    Wymagane: Nie
    Domyślny: null
Zobacz:
Powrót:
  • (string|false) A valid source size value for use in a 'sizes' attribute or false.
Zdefiniowane na:
Codex:

Retrieves the value for an image attachment's 'sizes' attribute.



Źródło

function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $image_meta = null ) {
	$image = wp_get_attachment_image_src( $attachment_id, $size );

	if ( ! $image ) {
		return false;
	}

	if ( ! is_array( $image_meta ) ) {
		$image_meta = wp_get_attachment_metadata( $attachment_id );
	}

	$image_src  = $image[0];
	$size_array = array(
		absint( $image[1] ),
		absint( $image[2] ),
	);

	return wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id );
}