Skip to content
This repository has been archived by the owner on Aug 24, 2018. It is now read-only.

Commit

Permalink
Add describedBy when alt is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Apr 6, 2017
1 parent e54d54b commit b4146ab
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion wp-includes/widgets/class-wp-widget-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ public function render_control_template_scripts() {

?>
<script type="text/html" id="tmpl-wp-media-widget-image-preview">
<#
var describedById = 'describedBy-' + String( Math.random() );
#>
<# if ( data.attachment.error && 'missing_attachment' === data.attachment.error ) { #>
<div class="notice notice-error notice-alt notice-missing-attachment">
<p><?php echo $this->l10n['missing_attachment']; ?></p>
Expand All @@ -292,7 +295,18 @@ public function render_control_template_scripts() {
<p><?php _e( 'Unable to preview media due to an unknown error.' ); ?></p>
</div>
<# } else if ( data.attachment.url || data.url ) { #>
<img class="attachment-thumb" src="{{ data.attachment.url || data.url }}" draggable="false" <# if ( data.alt ) { #>alt="{{ data.alt }}"<# } #> />
<img class="attachment-thumb" src="{{ data.attachment.url || data.url }}" draggable="false" alt="{{ data.alt }}" <# if ( ! data.alt ) { #> aria-describedby="{{ describedById }}" <# } #> />
<# if ( ! data.alt ) { #>
<#
var alt = ( data.attachment.url || data.url );
alt = alt.replace( /\?.*$/, '' );
alt = alt.replace( /^.+\//, '' );
#>
<p class="hidden" id="{{ describedById }}"><?php
/* translators: placeholder is image filename */
echo sprintf( __( 'Current image: %s' ), '{{ alt }}' );
?></p>
<# } #>
<# } #>
</script>
<?php
Expand Down

0 comments on commit b4146ab

Please sign in to comment.