Skip to content

Commit a3be6f1

Browse files
committed
Add 'title' shortcode attribute to use on iframe for accessibility
Default to 'Embedded PDF Document' if content author does not supply a custom title attribute BenjaminLawson#1
1 parent e6903c1 commit a3be6f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pdfjs-viewer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function pdfjs_shortcode_handler( $attr, $content, $tag ) {
4747
$attr = shortcode_atts(
4848
array(
4949
'url' => '',
50+
'title' => __( 'Embedded PDF Document', 'pdfjs-viewer-shortcode' ),
5051
'viewer_height' => '1360px',
5152
'viewer_width' => '100%',
5253
'fullscreen' => 'true',
@@ -101,11 +102,12 @@ function pdfjs_generator( $attr ) {
101102
}
102103

103104
return sprintf(
104-
'%1$s<iframe width="%2$s" height="%3$s" src="%4$s" ></iframe>',
105+
'%1$s<iframe width="%2$s" height="%3$s" src="%4$s" title="%5$s"></iframe>',
105106
$fullscreen_link,
106107
esc_attr( $attr['viewer_width'] ),
107108
esc_attr( $attr['viewer_height'] ),
108-
esc_url( $viewer_url )
109+
esc_url( $viewer_url ),
110+
esc_attr( $attr['title'] )
109111
);
110112
}
111113

0 commit comments

Comments
 (0)