sphinx-doc / sphinx-doc/sphinx
srcset in figure and image directives
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
The <img/> tag in html accepts a srcset to specify responsive image resolutions in websites (see https://html.com/attributes/img-srcset/). It would be great if the sphinx html builder accepted this as an option and copied the files to the build. eg:
.. image:: /images/my-image.png
:alt: Alt text
:srcset: /images/my-image.png, /images/my-image-2x.png 2.00x
would render as
<img src="_images/my-image.png" alt="Alt text" srcset="_images/my-image.png, _images/my-image-2x.png"/>
and the images would be copied to build/html/_images
Note that sphinx-gallery does this with a custom directive: .. image-sg:: (https://sphinx-gallery.github.io/dev/gen_modules/sphinx_gallery.directives.html#classes) and we are about to do it for Matplotlib, but for the figure directive.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Sphinx HTML builder's image and figure directives, then review the existing image-copying behavior and the related sphinx-gallery image-sg example. The work is done when image and figure directives accept srcset, render it in the HTML output, and copy the referenced images into the build's _images directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100