Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#151 2025-12-15 13:25:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Automatic thumbnails for Textpattern

etc wrote #341712:

Are there real-life situations when you need to change only one dimension?

Probably not. I’m inclined to think our original implementation on 4.earlier was wrong.

Should we also somehow take crop into account?

If we can, I guess. Not sure how.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#152 2025-12-15 13:57:49

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,199
Website GitHub

Re: Automatic thumbnails for Textpattern

etc wrote #341709:

I think there was a typo concerning the 1st variant, should work now.

That was it. I now get the following for a custom image with original dimensions 3857×2571 and a custom thumbnail of size 450×300:

<!-- <txp:article_image /> -->
<img src="http://thumbnail.test/images/13.jpg" alt="…" width="3857" height="2571">

<!-- <txp:article_image width="200" /> -->
<img src="http://thumbnail.test/images/13.jpg" alt="…" width="200" height="2571">

<!-- <txp:article_image thumbnail width="200" /> -->
<img src="http://thumbnail.test/images/13t.jpg" alt="…" width="200">

<!-- <txp:article_image thumbnail="1" width="200" /> -->
<img src="http://thumbnail.test/images/13t.jpg" alt="…" width="200">

<!-- <txp:article_image thumbnail="2" width="200" /> -->
<img src="http://thumbnail.test/images/thumb/cache/rendered/w200/13.jpg" alt="" width="200">

and for an automatically-generated thumbnail:

<!-- <txp:article_image /> -->
<img src="http://thumbnail.test/images/1.jpg" alt="…">

<!-- <txp:article_image width="200" /> -->
<img src="http://thumbnail.test/images/1.jpg" alt="…" width="200">

<!-- <txp:article_image thumbnail width="200" /> -->
<img src="http://thumbnail.test/images/thumb/cache/rendered/w200/1.jpg" alt="…" width="200">

<!-- <txp:article_image thumbnail="1" width="200" /> -->
<img src="http://thumbnail.test/images/1t.jpg" alt="…" width="200">

<!-- <txp:article_image thumbnail="2" width="200" /> -->
<img src="http://thumbnail.test/images/thumb/cache/rendered/w200/1.jpg" alt="" width="200">

(where the 1t.jpg doesn’t load because it doesn’t exist for auto-thumbnails)

so the behaviour is ever so slightly different between the two with respect to whether the height attribute is shown.


TXP Builders – finely-crafted code, design and txp

Offline

#153 2025-12-15 16:21:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Automatic thumbnails for Textpattern

Okay, /cache/rendered subdirectory is no more. Cached thumbnail subdirs should now be directly under the ‘thumb’ directory. Please test.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#154 2025-12-15 16:47:25

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,199
Website GitHub

Re: Automatic thumbnails for Textpattern

So far that seems perfect :-)


TXP Builders – finely-crafted code, design and txp

Offline

#155 2025-12-15 16:57:35

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: Automatic thumbnails for Textpattern

Bloke wrote #341713:

(re crop) If we can, I guess. Not sure how.

Me neither. Is exposing crop in tags useful at all? In my tests, crop="2x1" crops the image in the middle, which is natural, but a bit restrictive. Would not css suffice here?

Amazingly, one of my automatic thumbnails is always rotated, whatever I try. Can live with it, if it is only me.

Offline

#156 2025-12-15 17:14:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Automatic thumbnails for Textpattern

One step further: the request cache is entirely removed now.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#157 2025-12-15 21:13:56

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,199
Website GitHub

Re: Automatic thumbnails for Textpattern

Bloke wrote #341718:

One step further: the request cache is entirely removed now.

Cool! Things are moving thick and fast today. Everything works as before. 🥳

I’ve also tried out a couple of webp, avif, png, gif and svg files.

  • regular webp and avif files resized without any problems. The downsizing felt a bit blurry but it was a big file, so it may have been my example file. 👍
  • svg files are left as-is. 👍
  • transparent webp and png files are downsized correctly. 👍
  • animated webp and gif files render as static files.* 😯
  • gif transparency is rendered okay for custom files (if slightly pixelated) but for automatic thumbnails, transparent gif backgrounds are rendered in black. 🥷

*Presumably, the problem with animated images is a limitation of what GD is able to downsize (I vaguely remember something about having to split an animated file into the individual images, resize then recombine). ImageMagick may be able to do it out of the box…


TXP Builders – finely-crafted code, design and txp

Offline

#158 2025-12-15 21:31:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Automatic thumbnails for Textpattern

Yes, we’re stuck with GD’s limitations for animated content. At least it has a go at avif and gif. It won’t even entertain animated webp.

There’s a slight annoyance with our SVG implementation insofar as it always renders a token. That’s because there’s no thumbnail ever created; it just resizes the original.

We could do with detecting this $ext when we serve thumbnails and just bypass the token altogether since we won’t ever make thumbs from them so there’s no need to protect them.

I tried last night but ended up breaking svg support so I gave up.

Last edited by Bloke (2025-12-15 21:53:48)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#159 2025-12-15 21:42:52

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,199
Website GitHub

Re: Automatic thumbnails for Textpattern

Bloke wrote #341720:

There’s a slight annoyance with our SVG implementation insofar as it always renders a token … We could do with detecting this $ext when we serve thumbnails and just bypass the token altogether.

Agree.

What do you think about the black gif background? Is that maybe a just a missing setting in GD given that the transparent background works (in rudimentary gif-form) when the thumbnail is set to custom?


TXP Builders – finely-crafted code, design and txp

Offline

#160 2025-12-15 21:58:27

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Automatic thumbnails for Textpattern

jakob wrote #341721:

What do you think about the black gif background?

There’s a SLIR filter for background colour (not sure if it supports transparency: there’s no mention of alpha channels in their docs). Either way, it’s a weird one to offer as a tag attribute because it only applies to a few image formats, and would be ignored otherwise. I guess we could expose it and see what happens.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#161 2025-12-16 08:54:14

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,643
Website

Re: Automatic thumbnails for Textpattern

Things continue to work well after the latest tweeks. Happy to see those perf. improvements and those cleaner thumbnail image URL’s

Bloke wrote #341711:

It’s meant to currently return the size of the custom thumb from the database. Since the widths of the auto thumbs aren’t stored anywhere, we don’t necessarily know what width they are.

Thank you for confirming, I suspected as much. <txp:image_info type="thumb_w" /> is then only useful for custom thumbnails, for which I still have a few use cases.

jakob wrote #341719:

[…]

  • transparent webp and png files are downsized correctly. 👍

Really? My experience is a little different. Automatically generated thumbs for UI screenshots show a black border around the image – the transparent area. Oddly choosing custom thumbnail and let the system generate the image works surprising well, blurry but transparent and no odd border.

Think about images like here: l-c-n.com/stuff/sandspace-a-theme-for-the-textpattern-cms-admin-interface. If you want to try, here is the equivalent .webp image which will be in use soon. Try using <picture srcset="<txp:image_url thumbnail width="800" …> (half the size).

( I will continue using Acorn generated scaled down images for my screenshots!)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#162 2025-12-16 16:22:36

giz
Plugin Author
From: New Zealand
Registered: 2004-07-26
Posts: 433
Website GitHub Twitter

Re: Automatic thumbnails for Textpattern

etc wrote #341717:

Amazingly, one of my automatic thumbnails is always rotated, whatever I try. Can live with it, if it is only me.

The original was rotated (say in Preview.app) and then simply saved, but not re-exported.

Somewhere the Exif data is being ignored, resulting in an ‘un-rotated image’…

A occasional issue I get with slir is dealing with images with non-typical colour spaces. cmyk doesn’t work, and some greyscale formats break (only part of the image is rendered by slir).

Offline

#163 2025-12-16 16:38:26

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: Automatic thumbnails for Textpattern

giz wrote #341728:

The original was rotated (say in Preview.app) and then simply saved, but not re-exported.

That’s possible, all images from this source (not mine) get rotated by slir. But their ‘custom’ thumbnails are ok.

Offline

#164 2025-12-16 16:43:42

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: Automatic thumbnails for Textpattern

jakob wrote #341714:

the behaviour is ever so slightly different between the two with respect to whether the height attribute is shown.

Thanks for retesting, I will try to find time for tags consistency tweaks.

Offline

#165 2025-12-16 16:44:18

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,254
Website Mastodon

Re: Automatic thumbnails for Textpattern

Perhaps you can create a coloured rectangular image with a few words on it. Save as png or jpg. Load and see if the slir rotates it.


…. texted postive

Offline

Board footer

Powered by FluxBB