Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Change alt & title attributes of main product image to product name.
- add_filter('wp_get_attachment_image_attributes', 'taisho_change_image_attributes', 20, 2);
- function taisho_change_image_attributes($attr, $attachment) {
- global $post;
- if ($post->post_type == 'product') {
- $product = wc_get_product( $post->ID );
- $authortags = strip_tags ($product->get_tags());
- $title = $post->post_title;
- $attr['alt'] = $title .' '. $authortags;
- $attr['title'] = $title .' '. $authortags;
- }
- return $attr;
- }
- apply_filters( 'woocommerce_single_product_image_thumbnail_html', wc_get_gallery_image_html( $attachment_id ), $attachment_id );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement