Skip to content

Commit

Permalink
Add 'title' shortcode attribute to use on iframe for accessibility
Browse files Browse the repository at this point in the history
Default to 'Embedded PDF Document' if content author does not supply a custom title attribute BenjaminLawson#1
  • Loading branch information
richaber committed Jul 29, 2019
1 parent e6903c1 commit a3be6f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pdfjs-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function pdfjs_shortcode_handler( $attr, $content, $tag ) {
$attr = shortcode_atts(
array(
'url' => '',
'title' => __( 'Embedded PDF Document', 'pdfjs-viewer-shortcode' ),
'viewer_height' => '1360px',
'viewer_width' => '100%',
'fullscreen' => 'true',
Expand Down Expand Up @@ -101,11 +102,12 @@ function pdfjs_generator( $attr ) {
}

return sprintf(
'%1$s<iframe width="%2$s" height="%3$s" src="%4$s" ></iframe>',
'%1$s<iframe width="%2$s" height="%3$s" src="%4$s" title="%5$s"></iframe>',
$fullscreen_link,
esc_attr( $attr['viewer_width'] ),
esc_attr( $attr['viewer_height'] ),
esc_url( $viewer_url )
esc_url( $viewer_url ),
esc_attr( $attr['title'] )
);
}

Expand Down

0 comments on commit a3be6f1

Please sign in to comment.