Advertisement
lorro

WooCommerce - Remove alt texts

Jan 5th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?php
  2.   // function to slice out alt texts from WooCommerce images
  3.   // code goes in functions.php for your child theme
  4.  
  5.   // echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s" data-rel="prettyPhoto' . $gallery . '">%s</a>', $image_link, $image_caption, $image ), $post->ID );
  6.  
  7.   add_filter ('woocommerce_single_product_image_html', 'my_function');
  8.   function my_function($html) {
  9.    $start = stripos($html, 'alt="');
  10.     if ($start) {
  11.       $end = stripos($html, '"', $start + 5);
  12.       $html = substr($html, 0, $start - 1).substr($html, $end + 1);
  13.     }  
  14.     return $html;
  15.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement