[docutils:feature-requests] #102 Image height/width attributes

Günter Milde via Docutils-develop <[email protected]>
Newsgroups gmane.text.docutils.devel
Message-ID </p/docutils/feature-requests/102/8f8bc0d33e08d42397aed7cd242d782da54f3514.feature-requests@docutils.p.sourceforge.net>
Specifying the aspect-ratio via unitless "width" and "hight" is by now a valid use case.  Users  get a way to prevent layout shifts (e.g. specifying `:scale: 100`) while we retain the possibilty to overwrite document wide image dimension rules in a CSS stylesheet for a particular image in the "image" directive. 
As this is a backwards-incompatible change with the potential to break existing documents, it must be announced. See [r9617].


---

**[feature-requests:#102] Image height/width attributes**

**Status:** pending
**Group:** Default
**Created:** Wed Dec 20, 2023 02:35 PM UTC by toastal
**Last Updated:** Tue Mar 12, 2024 10:00 AM UTC
**Owner:** nobody


When setting `:width:` or `:height:` on an image, the output is a `<image style="width: $W; height: $H">`. This isn’t the expected out put as there are & have been `width` & `height` attributes for the `<img>` tag for a long time. One might assume this is the same affect, but there are some important problems & why I think this is a bug for incorrect implementation.

1. Tools like Lighthouse, et al. show users to have width/height as a optimization so the browser can calculate & the image size properly without having to do a layout shift which is great
2. A good CSP (Content Security Policy) should never include `unsafe-inline` as this can be an attack surface but the output of `:width:` & `:height:` do just this.

The way to solve this to keep out unneeded inline style practice for good CSP but still have the width/height is to just use `<img width="$W" height="$H">` (at least when units are not specified).

What I may not be accounting for: units. `12px` is not the same as `12rem` or `12ex` or `12vw`. However, what I had input in my image was just plain ol’ integers got back something I didn’t expect: a) something using `px` (I‘m exclusively using relative unit like `em`, `rem`, etc.) and b) not using the attributes since the number I gave had no units.


---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/docutils/feature-requests/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/feature-requests/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.