Skip to content
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

Image alt text is assigned to the image link rather than to the image itself #108

Open
zerotyr opened this issue Feb 1, 2024 · 2 comments

Comments

@zerotyr
Copy link

zerotyr commented Feb 1, 2024

I'm not sure where this issue actually lies (hugo vs. go-org). If this is the wrong repo, let me know.

I'm currently using hugo and org-mode to write blog posts. Note that I'm not using ox-hugo, but rather setting defaultMarkdownHandler = 'org' in hugo.toml. An issue I've run into is trying to find the correct way to provide alt text on images.

After a bit of experimentation, I figured out that the seemingly correct way to provide alt text for images was to supply the attribute alt to ATTR_HTML. However, the resulting HTML seems a bit odd to me. That said, I don't know how much this matters practice.

In the screenshot below, you'll see that the alt text is assigned to the link itself rather than the image, and the image is assigned the alt text of the file name provided in the org link's description.

* inline image with alt text
#+ATTR_HTML: :alt black mage rubbernecking bunny girl
[[file:./ffxiv-rubbernecking.png][file:./ffxiv-rubbernecking.png]]
<a href="./ffxiv-rubbernecking.png" alt="black mage rubbernecking bunny girl">
  <img src="./ffxiv-rubbernecking.png" alt="./ffxiv-rubbernecking.png">
</a>

Image

When performing an export on the same file using org-html-export-as-html, the alt text is assigned to both the link description and to the image itself as shown by the HTML generated by the export:

<a href="./ffxiv-rubbernecking.png" alt="black mage rubbernecking bunny girl">
  <img src="./ffxiv-rubbernecking.png" alt="black mage rubbernecking bunny girl"/>
</a>

When using alt text with an image without a description, it works as expected. However, this means my image is no longer clickable, so if the image was larger than the page, it wouldn't be possible to click on the image to see the larger version.

#+attr_html: :alt black mage rubbernecking bunny girl
[[file:./ffxiv-rubbernecking.png]]
<img src="./ffxiv-rubbernecking.png" alt="black mage rubbernecking bunny girl" title="./ffxiv-rubbernecking.png">

For me, the expected behavior is that the the alt text is assigned the same way when using org-html-export when using the org syntax in the first example provided, though I don't know if what org-export is doing is actually correct either from an accessibility standpoint.

If any more information is needed, let me know.

@niklasfasching
Copy link
Owner

Thx for the great report and sorry for the late reply. Totally makes sense, it's just a special case; we handle something similar for paragraphs that contain nothing but a link and set the attributes on the link rather than the containing paragraph (code). I'll get around to this eventually, but currently too much other stuff to work on.

@zerotyr
Copy link
Author

zerotyr commented Mar 25, 2024

no worries. thanks for looking into it. i may look into it myself to see if i can get it to work, though i'll need to teach myself go first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants