Skip to content

Commit

Permalink
Translatable aria-label for image compare block slider (#17501)
Browse files Browse the repository at this point in the history
Co-authored-by: Brad Jorsch <[email protected]>
  • Loading branch information
scottsweb and anomiex authored Oct 27, 2020
1 parent 8446773 commit 50c6a0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion extensions/blocks/image-compare/image-compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function register_block() {
*/
function load_assets( $attr, $content ) {
Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME );
wp_localize_script(
'jetpack-block-' . sanitize_title_with_dashes( FEATURE_NAME ),
'imageCompareHandle',
__( 'Slide to compare images', 'jetpack' )
);
if ( Blocks::is_amp_request() ) {
$content = preg_replace(
'#<div class="juxtapose".+?</div>#s',
Expand All @@ -49,7 +54,6 @@ function load_assets( $attr, $content ) {
return $content;
}


/**
* Render image compare block for AMP
*
Expand Down
4 changes: 4 additions & 0 deletions extensions/blocks/image-compare/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ domReady( function () {
this.controller.setAttribute( 'aria-valuenow', 50 );
this.controller.setAttribute( 'aria-valuemin', 0 );
this.controller.setAttribute( 'aria-valuemax', 100 );
this.controller.setAttribute(
'aria-label',
window.imageCompareHandle || 'Slide to compare images'
);

this.handle.appendChild( this.leftArrow );
this.handle.appendChild( this.control );
Expand Down

0 comments on commit 50c6a0e

Please sign in to comment.