| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template: Product Hero. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/orderable/hero.php |
| 6 |
* |
| 7 |
* HOWEVER, on occasion Orderable will need to update template files and you |
| 8 |
* (the theme developer) will need to copy the new files to your theme to |
| 9 |
* maintain compatibility. We try to do this as little as possible, but it does |
| 10 |
* happen. When this occurs the version of the template file will be bumped and |
| 11 |
* the readme will list any important changes. |
| 12 |
* |
| 13 |
* @package Orderable/Templates |
| 14 |
* |
| 15 |
* @var WC_Product_Variable $product Product. |
| 16 |
* @var array $args Array of args for the shortcode. |
| 17 |
*/ |
| 18 |
|
| 19 |
defined( 'ABSPATH' ) || exit; |
| 20 |
|
| 21 |
if ( ! $args['images'] ) { |
| 22 |
return; |
| 23 |
} |
| 24 |
?> |
| 25 |
|
| 26 |
<div class="orderable-product__hero"> |
| 27 |
<?php do_action( 'orderable_before_product_hero', $product, $args ); ?> |
| 28 |
|
| 29 |
<?php |
| 30 |
/** |
| 31 |
* Allow product hero image size to be updated. |
| 32 |
* |
| 33 |
* @param WC_Product $product Product. |
| 34 |
* @param array $args Argumentss passed to the Layout shortcode. |
| 35 |
* @since 1.6.0 |
| 36 |
*/ |
| 37 |
$orderable_product_hero_image_size = apply_filters( 'orderable_product_hero_image_size', 'woocommerce_thumbnail', $product, $args ); |
| 38 |
|
| 39 |
$srcset = false; |
| 40 |
|
| 41 |
$product_image_2x = Orderable_Helpers::get_product_image_2x( $product, $orderable_product_hero_image_size ); |
| 42 |
|
| 43 |
if ( $product_image_2x ) { |
| 44 |
$srcset = $product_image_2x['src'] . ' 2x'; |
| 45 |
} |
| 46 |
|
| 47 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 48 |
echo $product->get_image( |
| 49 |
$orderable_product_hero_image_size, |
| 50 |
[ |
| 51 |
'class' => 'orderable-product__image', |
| 52 |
'srcset' => esc_attr( $srcset ), |
| 53 |
] |
| 54 |
); |
| 55 |
?> |
| 56 |
|
| 57 |
<?php do_action( 'orderable_after_product_hero', $product, $args ); ?> |
| 58 |
</div> |
| 59 |
|