Loading
Draft: Resolve #3635968 "Add accessible titles"
Closes #3635968
Built on #3635944. This branch extends that issue’s test file, so the diff includes its commit (818ad9be). Review only the last commit: 316b3b25. Rebase onto 8.x-1.x once #3635944 is merged.
What this changes
Adds a title attribute to the frame element output by the Google Viewer, Microsoft Viewer and Direct Embed renderers, so screen readers announce the document instead of an unnamed frame.
The title is “PDF: [name]”, where the name is the first of these that exists:
- the media entity’s label, when the field is on a media entity (no dependency on the Media module)
- the file’s description
- the filename
Files
- pdf_reader.module: adds a title variable to the pdf_reader and pdf_reader_embed theme hooks
- FieldPdfReaderField.php: works out the title once per item
- pdf-reader.html.twig and pdf-reader-embed.html.twig: add title to the iframe / object
- PdfReaderFormatterTest.php: adds testFrameTitle for all three renderers, covering both the filename fallback and the file description
Not covered - pdf.js draws onto a canvas, not a frame, so naming it properly needs a separate issue.
Edited by whthat