Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-03-20 10:32:06

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

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

#2 2024-03-20 11:23:05

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,207
Website

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

#3 2024-03-20 13:03:55

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

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

Board footer

Powered by FluxBB