Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
txp:article_image width="0" height="0" Not giving expected result!
Hi
I tryed this code :
<txp:article_image width="0" height="0" />
I have got this result :
<img src="https://sitename/images/11.jpg" alt="" width="1000" height="1059">
Should it be without width and height ?
TXP 4.8.8
Thanks.
Offline
Re: txp:article_image width="0" height="0" Not giving expected result!
It is a bug in Textpattern 4.8.8, but don’t bother worrying, read on:
Leave, or specify (always), the width and height of images, that way the browser knows immediately the aspect ratio for that image (W/H), and how much (vertical) space to allocated. This avoids layout shifts while the image is downloaded.
In your stylesheet, you add:
img {
width: auto;
height: auto;
max-width: 100%;
}
This will always override the specified width/height specified in the HTML attribute. The image will never be wider that 100% of the container box, and the browser will automatically compute the correct height.
The reasoning behind all this: the browser downloads the stylesheet with highest priority, while images are downloaded with lower priority, thus the browser can easily compute the space (width and height) needed without having seen the image yet (just reading the HTML code).
–^–
I think somewhere on the forum there is a fix for that bug (?).
Last edited by phiw13 (2024-03-20 11:24:04)
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: txp:article_image width="0" height="0" Not giving expected result!
Hi
Thanks phiw13 for confirming it s a bug and for the workaround.
Cheers.
Offline