Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. // Change alt & title attributes of main product image to product name.
  2. add_filter('wp_get_attachment_image_attributes', 'taisho_change_image_attributes', 20, 2);
  3. function taisho_change_image_attributes($attr, $attachment) {
  4. global $post;
  5. if ($post->post_type == 'product') {
  6. $product = wc_get_product( $post->ID );
  7. $authortags = strip_tags ($product->get_tags());
  8. $title = $post->post_title;
  9. $attr['alt'] = $title .' '. $authortags;
  10. $attr['title'] = $title .' '. $authortags;
  11. }
  12. return $attr;
  13. }
  14.  
  15. 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