Update Variation Image Title/Alt

We should update the image title/alt when the product image changes for different variations.
This commit is contained in:
Scott Basgaard 2012-08-07 10:37:00 +02:00
parent f39c4e3626
commit 713f6fa6f5
2 changed files with 7 additions and 1 deletions

View File

@ -93,6 +93,7 @@ jQuery(document).ready(function($) {
var variation_image = variation.image_src;
var variation_link = variation.image_link;
var variation_title = variation.image_title;
$('.variations_button').show();
$('.single_variation').html( variation.price_html + variation.availability_html );
@ -108,6 +109,8 @@ jQuery(document).ready(function($) {
if (variation_image && variation_image.length > 1) {
$(img).attr('src', variation_image);
$(link).attr('href', variation_link);
$(img).attr('alt', variation_title);
$(img).attr('title', variation_title);
} else {
$(img).attr('src', o_src);
$(link).attr('href', o_href);

View File

@ -1077,8 +1077,10 @@ class WC_Product {
$attachment = wp_get_attachment_image_src( $attachment_id, 'full' );
$image_link = $attachment ? current( $attachment ) : '';
$image_title = get_the_title( $attachment_id );
} else {
$image = $image_link = '';
$image = $image_link = $image_title = '';
}
$available_variations[] = apply_filters( 'woocommerce_available_variation', array(
@ -1086,6 +1088,7 @@ class WC_Product {
'attributes' => $variation_attributes,
'image_src' => $image,
'image_link' => $image_link,
'image_title' => $image_title,
'price_html' => $this->min_variation_price != $this->max_variation_price ? '<span class="price">' . $variation->get_price_html() . '</span>' : '',
'availability_html' => $availability_html,
'sku' => __( 'SKU:', 'woocommerce' ) . ' ' . $variation->get_sku(),