Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#61 2025-12-06 09:10:47

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

Re: Automatic thumbnails for Textpattern

Bloke wrote #341565:

When we change the header, it effectively swallows any output.

The message can be seen in the image source. Inspecting the server response is the first thing I do in such cases.

Offline

#62 2025-12-06 09:18:14

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

Re: Automatic thumbnails for Textpattern

etc wrote #341567:

The message can be seen in the image source. Inspecting the server response is the first thing I do in such cases.

Yeah that’s what I do when debugging, but it doesn’t help people who are less well versed in using the inspector.


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

#63 2025-12-06 11:30:49

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

Re: Automatic thumbnails for Textpattern

The absence of the traditional 123t.ext thumbnail for automatic type looks debatable. We can adapt the core, but plugins like com_article_image expect it to be there when thumbnail != 0 in txp_image table. At least, imagesrcurl() function probably needs to be patched.

Offline

#64 2025-12-06 12:08:24

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

Re: Automatic thumbnails for Textpattern

If it’s a problem, we can always make it, regardless. Or patch com_article_image to understand thumbnail = 2.


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

#65 2025-12-06 18:13:21

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

Re: Automatic thumbnails for Textpattern

Would it be possible to force an output format when using <txp:image_url thumbnail width="123" />?

eg. .png to .jpg or .avif

I regularly come across poor PageSpeed rankings due to the format of the original image (typically .png used for photo imagery).

Offline

#66 2025-12-06 18:28:07

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

Re: Automatic thumbnails for Textpattern

giz wrote #341584:

Would it be possible to force an output format when using <txp:image_url thumbnail width="123" />?

Hmm, I can’t see that as a parameter in the docs. Under the hood it does a like-for-like downsize, retaining the original format.

In theory, once the incoming stream has been converted to an image in memory, it should be possible to divert it to a different format by overriding the default ‘use the same format’ when calling ->render(). But it’s tied internally to the mime type (because it needs to serve that) and there are function call upon call upon call that are chained together to detect those.

If I can unpick some of that, there might be a way we can wire up a parameter like /tavif/ and use that as the mime type and then it should spit out the converted image. I’ll have a play, but I’m not sure how successful it’ll be at this stage.

Last edited by Bloke (2025-12-06 18:30:14)


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

#67 2025-12-06 18:44:19

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

Re: Automatic thumbnails for Textpattern

Is there an option to create two alternative thumbnail resizing when uploading an image: ie. thumbnail 1 and thumbnail 2?
So that when uploading an image, say of a size 400×800, thumbnail 1 could be resized to 200×400 and thumbnail 2 to 100×200?
Would be useful to accommodate media sizes as in this example:

 <source srcset="https://mysite.ca/img/portfolio/screen-1-small.png" media="(max-width: 30em)">
       <source srcset="https://mysite.ca/img/portfolio/screen-1-medium.png" media="(max-width: 48em)">
         <source srcset="https://mysite.ca/img/portfolio/screen-1.png">

or should one simply create the alternate sizes before uploading?


…. texted postive

Offline

#68 2025-12-06 20:15:00

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

Re: Automatic thumbnails for Textpattern

bici wrote #341586:

Is there an option to create two alternative thumbnail resizing when uploading an image

There’s no need. That’s the point. If you want two or more different sizes in your srcset, just put the tags there and the images will be created at whatever widths / heights you specify.


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

#69 2025-12-06 21:30:45

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

Re: Automatic thumbnails for Textpattern

Bloke wrote #341588:

There’s no need. That’s the point. If you want two or more different sizes in your srcset, just put the tags there and the images will be created at whatever widths / heights you specify.

prefect! … I hadn’t realized that . But I still need one thumbnail so all good!


…. texted postive

Offline

#70 2025-12-06 21:53:01

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

Re: Automatic thumbnails for Textpattern

bici wrote #341586:

Is there an option to create two alternative thumbnail resizing when uploading an image … or should one simply create the alternate sizes before uploading?

Bloke wrote #341588:

There’s no need. That’s the point. If you want two or more different sizes in your srcset, just put the tags there and the images will be created at whatever widths / heights you specify.

bici, with the new method, you would do something like this for your situation (using your chosen widths and img id#s):

<txp:images id="1,2,3" wraptag="picture" break="">
  <source srcset="<txp:image_url thumbnail width="1600" />" media="(width >= 800px)">
  <source srcset="<txp:image_url thumbnail width="1200" />" media="(width >= 600px)">
  <img src="txp:image_url />" alt="txp:image_info type="alt" />">
</txp:images />

But if you wish to use the source tag expressly to art direct your images, i.e. your images are actually different at the respective sizes, you may need to go back to the old method of creating your individual sizes and uploading the other(s) as a thumbnail. If you have several, you’d still need smd_thumbnail for that.


TXP Builders – finely-crafted code, design and txp

Offline

#71 2025-12-07 02:58:06

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

Re: Automatic thumbnails for Textpattern

jakob wrote #341591:

bici, with the new method, you would do something like this for your situation (using your chosen widths and img id#s):

<txp:images id="1,2,3" wraptag="picture" break="">...

But if you wish to use the source tag expressly to art direct your images, i.e. your images are actually different at the respective sizes, you may need to go back to the old method of creating your individual sizes and uploading the other(s) as a thumbnail. If you have several, you’d still need smd_thumbnail for that.

tested and it works fine. thanks.


…. texted postive

Offline

#72 2025-12-08 08:59:38

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

Re: Automatic thumbnails for Textpattern

Inserting in the article body a <txp:article_image /> tag and assign an image ID in the article image field. View on the public side. Wall of text error: Fatal error: Uncaught Error: Call to undefined function imageBuild()@. Stack trace below (line breaks added for readability).

Before the recent image / thumbnail changes this worked fine.

Fatal error: Uncaught Error: Call to undefined function imageBuild() in /Users/username/Sites/phiw13-local/textpattern/publish/taghandlers.php:2110 
Stack trace: 
#0 [internal function]: article_image(Array, NULL) 
#1 /Users/username/Sites/phiw13-local/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func('article_image', Array, NULL) 
#2 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(540): Textpattern\Tag\Registry->process('article_image', Array, NULL) 
#3 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(429): processTags('article_image', '', NULL, false) 
#4 /Users/username/Sites/phiw13-local/textpattern/publish/taghandlers.php(1732): parse('<txp:article_im...') 
#5 /Users/username/Sites/phiw13-local/textpattern/publish/taghandlers.php(1763): txp_sandbox(Array) #6 [internal function]: body(Array, NULL) 
#7 /Users/username/Sites/phiw13-local/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func('body', Array, NULL) 
#8 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(540): Textpattern\Tag\Registry->process('body', Array, NULL) 
#9 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(429): processTags('body', '', NULL, false) 
#10 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_misc.php(3735): parse('<article class=...') 
#11 /Users/username/Sites/phiw13-local/textpattern/publish.php(1145): parse_form('default') 
#12 /Users/username/Sites/phiw13-local/textpattern/publish.php(1173): doArticle(Array, NULL) 
#13 /Users/username/Sites/phiw13-local/textpattern/publish.php(1008): parseArticles(Array, false, NULL) 
#14 [internal function]: article(Array, NULL) 
#15 /Users/username/Sites/phiw13-local/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func('article', Array, NULL) 
#16 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(540): Textpattern\Tag\Registry->process('article', Array, NULL) 
#17 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(429): processTags('article', '', NULL, false) 
#18 /Users/username/Sites/phiw13-local/textpattern/publish/taghandlers.php(2256): parse('\r\n<txp:if_secti...', false) 
#19 [internal function]: if_article_list(Array, '\r\n<txp:if_secti...') 
#20 /Users/username/Sites/phiw13-local/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func('if_article_list', Array, '\r\n<txp:if_secti...') 
#21 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(540): Textpattern\Tag\Registry->process('if_article_list', Array, '\r\n<txp:if_secti...')
#22 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_publish.php(429): processTags('if_article_list', '', '\r\n<txp:if_secti...', false) 
#23 /Users/username/Sites/phiw13-local/textpattern/lib/txplib_misc.php(3811): parse('<txp:smd_token ...') 
#24 /Users/username/Sites/phiw13-local/textpattern/publish.php(770): parse_page('archive', 'theme_25') 
#25 /Users/username/Sites/phiw13-local/index.php(81): textpattern() 
#26 {main} thrown in /Users/username/Sites/phiw13-local/textpattern/publish/taghandlers.php on line 2110

The form used is nearly stock forms/misc/images.txp that comes with the default install.

I tested this on local copy of a live site and a nearly vanilla install.


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

Offline

Board footer

Powered by FluxBB