Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-05-16 07:08:45

falkd
New Member
Registered: 2020-06-11
Posts: 6

Dimensionless img via height="0" width="0" works no more?

Hi!

I am struggling to find my mistake, as i want to leave the image-sizing to the css but:

<a href=”<txp:permlink />” class=“image featured”><txp:article_image thumbnail=“1” height=“0” width=“0” /></a>

results now in

<a href=“https://blog.falkduebbert.com/588/geschafft-eine-perfekte-woche” class=“image featured”><img src=“https://blog.falkduebbert.com/images/446t.jpg” alt=”“ width=“520” height=“640” ></a>

I don’t know if the last txp-, nginx- or php-update broke it. I did not change the code.

——

Textpattern version: 4.8.8 (958758a81a0a5e37d0d473c371064e48)
Last update: 2022-03-19 21:13:06/2022-01-24 13:32:38
Site URL: blog.falkduebbert.com
Admin URL: blog.falkduebbert.com/textpattern
Document root: /var/www/txp
$path_to_site: /var/www/txp
Textpattern path: /var/www/txp/textpattern
Article URL pattern: id_title
Production status: live
Temporary directory path: /var/www/txp/textpattern/tmp
PHP version: 7.2.34-28+0~20211119.67+debian9~1.gbpf24e81
GD Graphics Library: 2.2.5; Supported formats: GIF, JPEG, PNG, WebP.
Intl extension: Unavailable
Multibyte String extension: 7.2.34-28+0~20211119.67+debian9~1.gbpf24e81
Server time zone: Europe/Berlin
Server local time: 2022-05-16 08:59:35
Daylight Saving Time enabled?: 1
Automatically adjust Daylight Saving Time setting?: 1
Time zone (GMT offset in seconds): Europe/Berlin (3600)
MySQL: 5.5.5-10.1.48-MariaDB-0+deb9u2 (Debian 9.13)
Database server time: 2022-05-16 08:59:35
Database server time offset: 1 s
Database server time zone: SYSTEM
Database session time zone: SYSTEM
Locale: de_DE.UTF-8
Site / Admin language: de / de
Web server: nginx/1.19.6
PHP server API: fpm-fcgi
PHP SSL version: OpenSSL 1.1.0l 10 Sep 2019
RFC 2616 headers: 0
Server OS: Linux 4.9.0-11-amd64
Admin-side theme: hive 4.8.8

Last edited by falkd (2022-05-16 07:14:41)

Offline

#2 2022-05-16 11:14:54

etc
Developer
Registered: 2010-11-11
Posts: 4,662
Website GitHub

Re: Dimensionless img via height="0" width="0" works no more?

Hi,

did it ever work differently, and then in which setup?

Offline

#3 2022-05-16 11:51:32

falkd
New Member
Registered: 2020-06-11
Posts: 6

Re: Dimensionless img via height="0" width="0" works no more?

etc wrote #333307:

Hi,

did it ever work differently, and then in which setup?

Hi

in the past, and according to tag reference,

<a href=”<txp:permlink />” class=“image featured”><txp:article_image thumbnail=“1” height=“0” width=“0” /></a>

should result in

<a href=“https://blog.falkduebbert.com/588/geschafft-eine-perfekte-woche” class=“image featured”><img src=“https://blog.falkduebbert.com/images/446t.jpg” alt=”“></a>

So the CSS can take care of dimensions and margins.

But i don’t know which update broke it. I only updated debian / nginx via aptitude and txp by copying.

Last edited by falkd (2022-05-16 11:52:31)

Offline

#4 2022-05-16 14:33:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,743
Website GitHub

Re: Dimensionless img via height="0" width="0" works no more?

Good spot, thank you. This only affects the <txp:article_image> tag as it was optimised here and inadvertently broke zero-value attributes. We’ll fix this in a future release. Sorry for the hassle.

As a workaround, you can achieve the same effect with:

<if::article_image>
<txp:images>
<a href="<txp:permlink />" class="image featured"><txp:thumbnail width="0" height="0" /></a>
</txp:images>
</if::article_image>

The conditional isn’t technically necessary if you’re absolutely sure you always have an article image assigned. It’s only to cater for those eventualities when you haven’t, as it prevents the <txp:images> container tag from defaulting to display all pictures in the database.

Issue raised.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2022-05-16 17:25:58

falkd
New Member
Registered: 2020-06-11
Posts: 6

Re: Dimensionless img via height="0" width="0" works no more?

The workaround works for me. No long faces anymore.

THANK YOU!

Offline

#6 2022-05-16 18:43:10

etc
Developer
Registered: 2010-11-11
Posts: 4,662
Website GitHub

Re: Dimensionless img via height="0" width="0" works no more?

Bloke wrote #333318:

This only affects the <txp:article_image> tag as it was optimised here and inadvertently broke zero-value attributes.

Sorry, I can’t see how it could break them, it looks like a mere rewrite.

We’ll fix this in a future release. Sorry for the hassle.

That looks reasonable, but would it be bwc? I can’t find in which txp version width="0" meant no width. And then how would one output the real image width without knowing it? Valueless width, maybe?

Offline

#7 2022-05-16 21:45:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,743
Website GitHub

Re: Dimensionless img via height="0" width="0" works no more?

etc wrote #333331:

Sorry, I can’t see how it could break them, it looks like a mere rewrite.

It is. But for some reason (dunno why) the ‘or’ version in the rewrite seems to consider width='' and width='0' as the same. They’re not. The zero case was special and triggered ‘no attribute’ whereas the empty case triggered ‘use stored value’. Any other value used the given dimension explicitly.

Valueless width, maybe?

Must admit I tried that in my tests this afternoon, because it made sense to me. But that just triggered a 1px dimension image (it rendered width="1" in the markup).

Since the advent of fluid layouts, I’ve never been a fan of having people need to hack the image tag attributes to make them not output the dimensions. Seems backwards.

If it’s at all possible, we should re-engineer the tags so:

a) the default case is to output no size.
b) if you want the stored size, use a dimensionless attribute.
c) if you want an explicit size, specify it in the attribute.

Is that doable in a sort of backwards-compatible manner? Or should we just take the opportunity in 4.9 to break this as part of the image overhaul so it does actually work that way?

Seems more logical to opt in to render an image dimension, rather than opt out. BUT on the flipside, the browser won’t be able to allocate space for it until the image header is downloaded, so that may give flashes of reshuffling content, which is undesirable. Hmmmm.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2022-05-17 01:53:48

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 2,697
Website

Re: Dimensionless img via height="0" width="0" works no more?

Just fwiw, but setting width=0 and height=0 is considered a poor practice nowadays. the reasoning is that by specifying thos dimensions in the HTML you upfront indicate the aspect ratio of theimage and the browser optimises the layout from there. Next in your stylesheet, you can set width, max-width and height – catch-all: height: auto; no need for !important, the browsers treat the html attribute as something secondary at that point.


Where is that emoji for a solar powered submarine when you need it ?

Offline

#9 2022-05-17 07:15:41

etc
Developer
Registered: 2010-11-11
Posts: 4,662
Website GitHub

Re: Dimensionless img via height="0" width="0" works no more?

Bloke wrote #333333:

for some reason (dunno why) the ‘or’ version in the rewrite seems to consider width='' and width='0' as the same. They’re not. The zero case was special and triggered ‘no attribute’ whereas the empty case triggered ‘use stored value’. Any other value used the given dimension explicitly.

Ah, $width must be a string here, so the loose $width== '' comparison is false. To complicate things even more, PHP has changed 0 == '' result from true to false in some recent version. My bad for not having tested this thoroughly.

If it’s at all possible, we should re-engineer the tags so:

a) the default case is to output no size.
b) if you want the stored size, use a dimensionless attribute.
c) if you want an explicit size, specify it in the attribute.

Is that doable in a sort of backwards-compatible manner? Or should we just take the opportunity in 4.9 to break this as part of the image overhaul so it does actually work that way?

If 4.9 is cf then we’ll have to sacrify some bwc anyway, imo.

Offline

#10 2022-05-17 08:04:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,743
Website GitHub

Re: Dimensionless img via height="0" width="0" works no more?

etc wrote #333339:

PHP has changed 0 == '' result from true to false in some recent version.

rolleyes Thanks, PHP.

No worries. There’s a workaround for this tiny thing, and we should change the image tags anyway to be more modern in their approach – srcset/sizes support, etc – so it’s definitely the right time to revisit this and make rendering the dimension attributes opt-in, if it makes sense to do so.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#11 2022-05-17 09:05:46

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,851
Website

Re: Dimensionless img via height="0" width="0" works no more?

etc wrote #333339:

If 4.9 is cf …

CFs? As in unlimited? / rubs hands /

Offline

#12 2022-05-17 15:21:29

etc
Developer
Registered: 2010-11-11
Posts: 4,662
Website GitHub

Re: Dimensionless img via height="0" width="0" works no more?

Destry wrote #333349:

CFs? As in unlimited? / rubs hands /

4.9 is profiled ‘imagery’, but I’m null in this stuff, so cf is appealing…

Offline

Board footer

Powered by FluxBB