ipq_get_theme_image( int $post_id, array $sizes, string $attr = '' )
Get image HTML for a specific context in a theme, specifying the exact sizes for the image. The first image size is always used as the src
and the other sizes are used in the srcset
if they’re the same aspect ratio as the original image. If any of the image sizes don’t currently exist, they are queued for creation by a background process. Example:
Description
For echoing – echo ipq_get_theme_image( 1353, array( array( 600, 400, false ), array( 1280, 720, false ), array( 1600, 1067, false ), ), array( ‘class’ => ‘header-banner’ ) );
Parameters
- $post_id
-
(int) (Required) Image attachment ID.
- $sizes
-
(array) (Required) Array of arrays of sizes in the format array(width,height,crop).
- $attr
-
(string) (Optional) Attributes for the image markup.
Default value: ''
Return
(string) HTML img element or empty string on failure.
Source
File: classes/library/image-processing-queue/includes/ipq-template-functions.php
function ipq_get_theme_image( $post_id, $sizes, $attr = '' ) { return Image_Processing_Queue::instance()->get_image( $post_id, $sizes, $attr ); }
Expand full source code Collapse full source code View on Trac