daily pastebin goal
47%
SHARE
TWEET

WooCommerce - Remove alt texts

lorro Jan 5th, 2016 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top