Automattic\WooCommerce\Internal\VariationGallery
ClassicVariationGalleryAdmin::render_hero_image
Render the hero image.
Method of the class: ClassicVariationGalleryAdmin{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->render_hero_image( $image_id ): void;
- $image_id(int) (required)
- Attachment ID.
ClassicVariationGalleryAdmin::render_hero_image() ClassicVariationGalleryAdmin::render hero image code WC 10.9.1
<?php
private function render_hero_image( int $image_id ): void {
$html = wp_get_attachment_image(
$image_id,
'woocommerce_single',
false,
array(
'class' => 'wc-variation-gallery-field__hero-img',
'data-id' => (string) $image_id,
'decoding' => 'async',
'loading' => 'lazy',
)
);
if ( '' === $html ) {
?>
<span class="wc-variation-gallery-field__hero-broken" aria-hidden="true">
<span class="dashicons dashicons-format-image"></span>
</span>
<span class="screen-reader-text">
<?php esc_html_e( 'Attachment file missing', 'woocommerce' ); ?>
</span>
<?php
return;
}
echo wp_kses_post( $html );
}