Theming Exchange - Getting a Product Image of Any Registered Size
Although you can use
it_exchange( 'product', 'featured-image' ); or
it_exchange( 'product', 'gallery' ); to return a product's images within a loop, there is also a function you can use to return product images of all sizes.
it_exchange( 'product', 'get-images' );
For example, if you have a product with one image and use the
get-images function this will be the output.
Array 123 => Array thumbnail => Array 0 => http://example.com/path-to-image/image-150x150.jpg 1 => [integer] 150 2 => [integer] 150 3 => true medium => Array 0 => http://example.com/path-to-image/image-300x181.jpg 1 => [integer] 300 2 => [integer] 181 3 => true large => Array 0 => http://example.com/path-to-image/image-1024x618.jpg 1 => [integer] 1024 2 => [integer] 618 3 => true full => Array 0 => http://example.com/path-to-image/image.jpg 1 => [integer] 4400 2 => [integer] 2656 3 => false
Where 123 is the ID of the image, followed by the available sizes.
Note that the image sizes will be different depending on the images uploaded.
Retrieving a Specific Image
You can take this function one step further by adding an ID & size to retrieve a specific product image of that size.
it_exchange( 'product', 'get-images', array( 'id' => '123', 'size' => 'full' ) );
Array 0 => http://example.com/path-to-image/image.jpg 1 => [integer] 4400 2 => [integer] 2656 3 => false
- Theming Exchange
- Getting Started
- Customize Exchange Generated Pages Output
- Adding Custom Templates
- Functions List
- Exchange Theme Templates
- Template Updates