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

Feature request: Ability to wrap output in a <figure> tags. #249

Open
Nooshu opened this issue Oct 8, 2024 · 3 comments
Open

Feature request: Ability to wrap output in a <figure> tags. #249

Nooshu opened this issue Oct 8, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Nooshu
Copy link

Nooshu commented Oct 8, 2024

It would be fantastic if there was the option to wrap the standard <picture> element from the eleventyImageTransformPlugin in a <figure> tags and allow developers to post image captions using <figcaption>.

Proposed code:
Input
![This is the alt text](path/to/the/image.jpg "This is the **caption**")

Output

<figure>
  <picture>
    <source type="image/avif" srcset="/.11ty/image/?src=...">
    <source type="image/webp" srcset="/.11ty/image/?src=...">
    <img loading="lazy" decoding="async" src="/.11ty/image/?src=..." alt="alt text here" width="123" height="321">
  </picture>
  <figcaption>This is the <strong>caption</strong></figcaption>
</figure>

Looping in @nhoizey as I adapted his gist example here that he uses with his eleventy-plugin-images-responsiver plugin here.

Update: Also, I should have noted that the <figure> element would only be present if a caption was given in the markdown snippet.

@zachleat
Copy link
Member

Just for completeness, I should mention that if you’re using markdown now, you can use this input now and the transform plugin will output what you want there above:

<figure>
  <img src="path/to/the/image.jpg" alt="This is the alt text">
  <figcaption>This is the <strong>title</strong></figcaption>
</figure>

@zachleat zachleat added the enhancement New feature or request label Dec 20, 2024
@zachleat
Copy link
Member

 ![This is the alt text](path/to/the/image.jpg "This is the **caption**")

The above isn’t stock Markdown syntax, right?

@nhoizey
Copy link

nhoizey commented Dec 20, 2024

The above isn’t stock Markdown syntax, right?

The syntax is standard CommonMark (if this is what you call "stock" Markdown), but it generates a title attribute: https://spec.commonmark.org/0.31.2/#images

Expending the title as a <figure> and <figcaption> has been a popular demand for 10 years:
https://talk.commonmark.org/t/image-tag-should-expand-to-figure-when-used-with-title/265

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

No branches or pull requests

3 participants