Add the function below to your child theme functions.php file.
// adding alt tags to product images add_filter(โwp_get_attachment_image_attributesโ, โchange_attachement_image_attributesโ, 20, 2); function change_attachement_image_attributes( $attr, $attachment ){ // Get post parent $parent = get_post_field( โpost_parentโ, $attachment); // Get post type to check if itโs product $type = get_post_field( โpost_typeโ, $parent); if( $type != โproductโ ){ return $attr; } /// Get title $title = get_post_field( โpost_titleโ, $parent); $attr[โaltโ] = $title; $attr[โtitleโ] = $title; return $attr; }