WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

Automattic\WooCommerce\Blocks\StoreApi\Schemas

ImageAttachmentSchema::get_item_response() public WC 1.0

Convert a WooCommerce product into an object suitable for the response.

{} Это метод класса: ImageAttachmentSchema{}

Хуков нет.

Возвращает

Массив/null.

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

$ImageAttachmentSchema = new ImageAttachmentSchema();
$ImageAttachmentSchema->get_item_response( $attachment_id );
$attachment_id(число) (обязательный)
Image attachment ID.

Код ImageAttachmentSchema::get_item_response() WC 4.7.1

<?php
public function get_item_response( $attachment_id ) {
	if ( ! $attachment_id ) {
		return null;
	}

	$attachment = wp_get_attachment_image_src( $attachment_id, 'full' );

	if ( ! is_array( $attachment ) ) {
		return [];
	}

	$thumbnail = wp_get_attachment_image_src( $attachment_id, 'woocommerce_thumbnail' );

	return [
		'id'        => (int) $attachment_id,
		'src'       => current( $attachment ),
		'thumbnail' => current( $thumbnail ),
		'srcset'    => (string) wp_get_attachment_image_srcset( $attachment_id, 'full' ),
		'sizes'     => (string) wp_get_attachment_image_sizes( $attachment_id, 'full' ),
		'name'      => get_the_title( $attachment_id ),
		'alt'       => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ),
	];
}