PHP 8.2.31
Preview: ImageAttachmentSchema.php Size: 2.55 KB
//home/nshryvcy/taramarriagebureau.com/wp-content/plugins/woocommerce/src/StoreApi/Schemas/V1/ImageAttachmentSchema.php

<?php
namespace Automattic\WooCommerce\StoreApi\Schemas\V1;

/**
 * ImageAttachmentSchema class.
 */
class ImageAttachmentSchema extends AbstractSchema {
	/**
	 * The schema item name.
	 *
	 * @var string
	 */
	protected $title = 'image';

	/**
	 * The schema item identifier.
	 *
	 * @var string
	 */
	const IDENTIFIER = 'image';

	/**
	 * Product schema properties.
	 *
	 * @return array
	 */
	public function get_properties() {
		return [
			'id'        => [
				'description' => __( 'Image ID.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => [ 'view', 'edit' ],
			],
			'src'       => [
				'description' => __( 'Full size image URL.', 'woocommerce' ),
				'type'        => 'string',
				'format'      => 'uri',
				'context'     => [ 'view', 'edit' ],
			],
			'thumbnail' => [
				'description' => __( 'Thumbnail URL.', 'woocommerce' ),
				'type'        => 'string',
				'format'      => 'uri',
				'context'     => [ 'view', 'edit' ],
			],
			'srcset'    => [
				'description' => __( 'Thumbnail srcset for responsive images.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => [ 'view', 'edit' ],
			],
			'sizes'     => [
				'description' => __( 'Thumbnail sizes for responsive images.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => [ 'view', 'edit' ],
			],
			'name'      => [
				'description' => __( 'Image name.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => [ 'view', 'edit' ],
			],
			'alt'       => [
				'description' => __( 'Image alternative text.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => [ 'view', 'edit' ],
			],
		];
	}

	/**
	 * Convert a WooCommerce product into an object suitable for the response.
	 *
	 * @param int $attachment_id Image attachment ID.
	 * @return object|null
	 */
	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 null;
		}

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

		return (object) [
			'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 ),
		];
	}

}

Directory Contents

Dirs: 1 × Files: 28

Name Size Perms Modified Actions
AI DIR
- drwxr-xr-x 2026-03-03 06:25:16
Edit Download
10.46 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
12.83 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
427 B lrw-r--r-- 2026-03-03 06:25:16
Edit Download
4.46 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
3.19 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.21 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.12 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
7.56 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
16.22 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
11.37 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
752 B lrw-r--r-- 2026-03-03 06:25:16
Edit Download
14.90 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
1.12 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.55 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
11.00 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.41 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.20 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.79 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
12.74 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
673 B lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.50 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
3.49 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
3.50 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
4.18 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
6.12 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
32.48 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.84 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download
2.15 KB lrw-r--r-- 2026-03-03 06:25:16
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).