ProductGalleryUtils
in package
Utility methods used for the Product Gallery block.
Table of Contents
- get_all_image_ids() : array<string|int, mixed>
- Get all image IDs for the product.
- get_image_src_data() : array<string|int, mixed>
- Get the image source data.
- get_product_gallery_image_count() : int
- Get the product gallery image count.
- get_product_gallery_image_data() : array<string|int, mixed>
- Get the product gallery image data.
- get_product_gallery_image_ids() : array<string|int, mixed>
- Get the product gallery image IDs.
- get_product_variation_image_ids() : array<string|int, mixed>
- Get the product variation image data.
Methods
get_all_image_ids()
Get all image IDs for the product.
public
static get_all_image_ids(WC_Product $product) : array<string|int, mixed>
Parameters
- $product : WC_Product
-
The product object.
Return values
array<string|int, mixed> — An array of image IDs.get_image_src_data()
Get the image source data.
public
static get_image_src_data(array<string|int, mixed> $image_ids, string $size[, string $product_title = '' ]) : array<string|int, mixed>
Parameters
- $image_ids : array<string|int, mixed>
-
The image IDs to retrieve the source data for.
- $size : string
-
The size of the image to retrieve.
- $product_title : string = ''
-
The title of the product used for alt fallback.
Return values
array<string|int, mixed> — An array of image source data.get_product_gallery_image_count()
Get the product gallery image count.
public
static get_product_gallery_image_count(WC_Product $product) : int
Parameters
- $product : WC_Product
-
The product object to retrieve the gallery images for.
Return values
int — The number of images in the product gallery.get_product_gallery_image_data()
Get the product gallery image data.
public
static get_product_gallery_image_data(WC_Product $product, string $size) : array<string|int, mixed>
Parameters
- $product : WC_Product
-
The product object to retrieve the gallery images for.
- $size : string
-
The size of the image to retrieve.
Return values
array<string|int, mixed> — An array of image data for the product gallery.get_product_gallery_image_ids()
Get the product gallery image IDs.
public
static get_product_gallery_image_ids(WC_Product $product) : array<string|int, mixed>
Parameters
- $product : WC_Product
-
The product object to retrieve the gallery images for.
Return values
array<string|int, mixed> — An array of unique image IDs for the product gallery.get_product_variation_image_ids()
Get the product variation image data.
public
static get_product_variation_image_ids(WC_Product $product) : array<string|int, mixed>
Parameters
- $product : WC_Product
-
The product object to retrieve the variation images for.