diff --git a/plugins/woocommerce-blocks/src/BlockTypes/FeaturedItem.php b/plugins/woocommerce-blocks/src/BlockTypes/FeaturedItem.php index 4decc617dce..aeb7d340242 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/FeaturedItem.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/FeaturedItem.php @@ -201,7 +201,8 @@ abstract class FeaturedItem extends AbstractDynamicBlock { * @return string */ private function render_image( $attributes, $item, string $image_url ) { - $style = sprintf( 'object-fit: %s;', esc_attr( $attributes['imageFit'] ) ); + $style = sprintf( 'object-fit: %s;', esc_attr( $attributes['imageFit'] ) ); + $img_alt = $attributes['alt'] ?: $this->get_item_title( $item ); if ( $this->hasFocalPoint( $attributes ) ) { $style .= sprintf( @@ -214,7 +215,7 @@ abstract class FeaturedItem extends AbstractDynamicBlock { if ( ! empty( $image_url ) ) { return sprintf( '%1$s', - wp_kses_post( $attributes['alt'] ?: $this->get_item_title( $item ) ), + esc_attr( $img_alt ), $this->block_name, esc_url( $image_url ), esc_attr( $style )