Merge pull request #22865 from woocommerce/fix/22863
Add alt text to gallery thumbnail
This commit is contained in:
commit
dbe93b96c4
|
@ -1426,6 +1426,7 @@ function wc_get_gallery_image_html( $attachment_id, $main_image = false ) {
|
||||||
$full_size = apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) );
|
$full_size = apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) );
|
||||||
$thumbnail_src = wp_get_attachment_image_src( $attachment_id, $thumbnail_size );
|
$thumbnail_src = wp_get_attachment_image_src( $attachment_id, $thumbnail_size );
|
||||||
$full_src = wp_get_attachment_image_src( $attachment_id, $full_size );
|
$full_src = wp_get_attachment_image_src( $attachment_id, $full_size );
|
||||||
|
$alt_text = trim( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) );
|
||||||
$image = wp_get_attachment_image(
|
$image = wp_get_attachment_image(
|
||||||
$attachment_id,
|
$attachment_id,
|
||||||
$image_size,
|
$image_size,
|
||||||
|
@ -1447,7 +1448,7 @@ function wc_get_gallery_image_html( $attachment_id, $main_image = false ) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return '<div data-thumb="' . esc_url( $thumbnail_src[0] ) . '" class="woocommerce-product-gallery__image"><a href="' . esc_url( $full_src[0] ) . '">' . $image . '</a></div>';
|
return '<div data-thumb="' . esc_url( $thumbnail_src[0] ) . '" data-thumb-alt="' . esc_attr( $alt_text ) . '" class="woocommerce-product-gallery__image"><a href="' . esc_url( $full_src[0] ) . '">' . $image . '</a></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! function_exists( 'woocommerce_output_product_data_tabs' ) ) {
|
if ( ! function_exists( 'woocommerce_output_product_data_tabs' ) ) {
|
||||||
|
|
Loading…
Reference in New Issue