wordpress - How to control HTML output of variable $image in WooCommerce -


i'm using woocommerce , on single product page have overview of product images. call images product-thumbnails.php template, result conflicts css because output of $image adds pixel size in html.

now:

<img src="http://example.com/image.jpg" height="480" width="360"> 

desired:

<img src="http://example.com/image.jpg"> 

how can change output of $image?

html5blank has pretty example should answer of questions, take here - spefically line 206 , actions it's hooked into:

add_filter('post_thumbnail_html', 'remove_width_attribute', 10 );  function remove_width_attribute( $html ) {    $html = preg_replace( '/(width|height)="\d*"\s/', "", $html );    return $html; } 

to target template you're referring hook filter (woocommerce_single_product_image_thumbnail_html) , modify function little such:

add_action('woocommerce_single_product_image_thumbnail_html','remove_single_product_image_attrs',10,4);  function remove_single_product_image_attrs( $image_html, $attachment_id, $post, $image_class ){     return preg_replace( '/(width|height)="\d*"\s/', "", $image_html ); } 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -