acf_get_attachment_image()ACF 5.5.0

acf_get_attachment_image

description

@type    function

Хуков нет.

Возвращает

$post_id. (int)

Использование

acf_get_attachment_image( $attachment_id, $size );
$attachment_id **
-
$size **
-
По умолчанию: 'thumbnail'

Список изменений

С версии 5.5.0 Введена.

Код acf_get_attachment_image() ACF 5.10.2

function acf_get_attachment_image( $attachment_id = 0, $size = 'thumbnail' ) {

	// vars
	$url = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
	$alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );

	// bail early if no url
	if ( ! $url ) {
		return '';
	}

	// return
	$value = '<img src="' . $url . '" alt="' . $alt . '" />';

}