-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No alt text for 'bg' images #368
Comments
When used import { Marpit } from '@marp-team/marpit'
const marpit = new Marpit()
const { html } = marpit.render('# Hello ![bg Alternative text](https://example.com/image.jpg)')
console.log(html) <div class="marpit">
<section id="1" data-background-image="url("https://example.com/image.jpg")" style="--background-image:url("https://example.com/image.jpg");background-image:url("https://example.com/image.jpg");background-position:center;background-repeat:no-repeat;background-size:cover;">
<h1>Hello </h1>
</section>
</div> Using the
I suppose it's difficult to associate text alternatives to the background image when rendered with Marpit default mode, because appending When Marpit has adopted the advanced background mode by enabled inline SVG mode, const marpit = new Marpit({ inlineSVG: true })
const { html } = marpit.render('# Hello ![bg Alternative text](https://example.com/image.jpg)') <div class="marpit">
<svg data-marpit-svg="" viewBox="0 0 1280 720">
<foreignObject width="1280" height="720">
<section data-marpit-advanced-background="background">
<div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal">
<figure style="background-image:url("https://example.com/image.jpg");"></figure>
</div>
</section>
/foreignObject>
<foreignObject width="1280" height="720">
<section id="1" data-marpit-advanced-background="content">
<h1>Hello </h1>
</section>
</foreignObject>
<foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo">
<section data-marpit-advanced-background="pseudo" style=""></section>
</foreignObject>
</svg>
</div> In this case, I suppose we might associate text alternatives to each background images by using <figure style="background-image:url("https://example.com/image.jpg");">
<figcaption>Alternative text</figcaption>
</figure> We have to append new CSS to the base style of advanced background images, to hide them from the screen. marpit/src/postcss/advanced_background.js Lines 50 to 57 in e926440
|
Thank you for your quick reply! I think this is a good solution, for some background images for example those which provide corporate colours/logos there would probably be no alternative text. In other instances where the background image is being used to illustrate something in the text which is often the case in presentations, the alternative text is essential for accessibility. Thank you also for Marp, I've been using it for all my lecture notes, conference presentations and other slide decks since 2017! |
Shipped as Marpit v2.5.1. Please be patient for updation of downstream Marp ecosystem tools. :) |
I'm using a lot of 'bg' tagged images to provide images alongside the text of my presentations, for example
The alt text works for other images, but not these? There's a big push within my institution to make all slides accessible for screen readers. I can understand the alt text being ignored for a background image, but where part of the slide is taken up with an image relevant to the text this requires alt text for screen readers.
The text was updated successfully, but these errors were encountered: