Advertisement
fauzanjeg

JKIT || Example Output Filter of WooCommerce Product Images

Oct 13th, 2024
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. /**
  2.  * JKIT || Example Output Filter of WooCommerce Product Images
  3.  *
  4.  * Add Caption to Product Images
  5.  *
  6.  * @param string     $html Rendered HTML.
  7.  * @param WC_Product $class Class of WC_Product.
  8.  * @param string     $size (default: 'woocommerce_thumbnail').
  9.  * @param array      $attr Image attributes.
  10.  * @param bool       $placeholder True to return $placeholder if no image is found, or false to return an empty string.
  11.  * @param string     $image Rendered Image HTML.
  12.  *
  13.  * @return string
  14.  */
  15. function add_caption_to_product_images( $html, $class, $size, $attr, $placeholder, $image ) {
  16.     $html .= '<h6>Custom Caption</h6>';
  17.  
  18.     return $html;
  19. }
  20. add_filter( 'woocommerce_product_get_image', 'add_caption_to_product_images', 10, 6 );
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement