Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#277 2025-12-27 20:16:59

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

Re: Automatic thumbnails for Textpattern

Right click a thumbnail that purports to be automatic (i.e. has /thumb/w800/… in it) and open in a new tab. If the process is failing you should see an error message in the browser.


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

#278 2025-12-27 23:00:39

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

Re: Automatic thumbnails for Textpattern

I get a 404 and this page source:

<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

and this response:

Übersicht
URL: https://domain.com/images/thumb/w800/1.jpg?token=8140119e540a03e3fa8a0f587490f68f22e99ff0bfa06d4297ec1bacf1fd8e48
Status: 404
Quelle: Netzwerk
Adresse: xxx.xxx.xxx.xxx:443

Anfrage
:method: GET
:scheme: https
:authority: domain.com
:path: /images/thumb/w800/1.jpg?token=8140119e540a03e3fa8a0f587490f68f22e99ff0bfa06d4297ec1bacf1fd8e48
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: de-DE,de;q=0.9
Cookie: txp_login_public=986048ffd3julian; PHPSESSID=e310c00047975644b7a08ef70a222c94
Priority: u=0, i
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15

Antwort
:status: 404
Content-Encoding: br
Content-Type: text/html
Date: Sat, 27 Dec 2025 22:59:58 GMT
Server: nginx
Vary: Accept-Encoding

Parameter der Abfragezeichenkette
token: 8140119e540a03e3fa8a0f587490f68f22e99ff0bfa06d4297ec1bacf1fd8e48

TXP Builders – finely-crafted code, design and txp

Offline

#279 2025-12-27 23:43:16

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

Re: Automatic thumbnails for Textpattern

I think I’ve identified it as a problem in the default nginx vhost that I don’t quite understand yet.

It has a section as follows:

  location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map|mjs)$ {
    add_header Access-Control-Allow-Origin "*";
    add_header alt-svc 'h3=":443"; ma=86400';
    expires max;
    access_log off;
  }

Removing jpg|jpeg from that list allows the images to appear. I need to learn what that means and then see what I should correct or exclude from that. But that’s a problem for tomorrow.

EDIT: Additional observations after further investigation:

Normal images seem to be handled just fine, so it looks like just the initial redirect to thumbnail creation situation that occurs when a token is passed isn’t being handled. To test that, I temporarily removed the image extensions from that list allows txp to create the thumbs, then restored the original nginx directive including the image extensions. The thumbnails created in the /images/thumb/…directories now work, just the new creation of thumbs doesn’t.

@gaekward or anyone else? Is there a way of either passing through image requests that result in a 404 or 301 to the thumbnail creation routine, and / or is there a way of excluding location regexs that contain a ?token= url parameter from this directive?


TXP Builders – finely-crafted code, design and txp

Offline

#280 Today 02:45:58

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

Re: Automatic thumbnails for Textpattern

none of these two options output the correct size image:
I have then in a TXP Form:

<txp:thumbnail id="16" class="portfolio__nav__img" />  

The thumbnail sizes on the Images panel is at 324×200 , but the image output is large … but if I right click to show image in a new window it is the proper size.

This also fails to render a small 324×200 image:

<img src="../images/16t.png" width="324" height="200" alt="nav" class="portfolio__nav__img">

but if I enter this html

<a href="https://example.ca/portfolio/bikes_wheels" class="portfolio__nav__item grid__item one-half medium--one-half wide--one-third is-active">
	<img src="https://example.ca/assets/portfolio/nav-bici.png" width="324" height="200" alt="nav-solutions" class="portfolio__nav__img">
		<h4 class="portfolio__nav__title">BikeHistory</h4>
	<div class="portfolio__nav__role">Website Design</div>
</a><!-- 1 -->

the image is output at the right size of 324×200

Last edited by bici (Today 03:15:27)


…. texted postive

Offline

#281 Today 06:17:42

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

Re: Automatic thumbnails for Textpattern

bici wrote #342225:

none of these two options output the correct size image

You need to specify at least a width to get a resized thumbnail. And in the 2nd example, you’re trying to output the ‘t’ version which is a custom thumb. Does it exist? And why the path ../images?

Also, what type of thumbnail is image id 16? Automatic? Custom? None?


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

#282 Today 07:35:06

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

Re: Automatic thumbnails for Textpattern

bici wrote #342225:

none of these two options output the correct size image:

You have several variants there that all slightly miss the mark.

  1. The first needs a width="324 to trigger the automatic thumbnail generation.
  2. The second doesn’t use a Textpattern tag and targets a /images/#t.jpg file. That could work if your thumbnail is the custom type (e.g. how things have always been in Textpattern prior to the automatic thumbnailing capabiity). For that you need to have “custom” as the thumbnail type and have created a corresponding thumbnail file in the Content › Images panel.
  3. The third likewise doesn’t use a Textpattern tag and targets an image you likely uploaded via FTP in the /assets/ directory.

In short, if you want to use automatic thumbnail generation, what you probably want is:

<txp:permlink class="portfolio__nav__item grid__item one-half medium--one-half wide--one-third is-active">
	<txp:article_image width="324" limit="1" class="portfolio__nav__img" />
	<txp:title wraptag="h4" class="portfolio__nav__title" />
	<txp:category1 wraptag="div" class="portfolio__nav__role" />
</txp:permlink>

or something along those lines. This assumes you have the image id in the article image field and have used Category 1 for your project type classification.


TXP Builders – finely-crafted code, design and txp

Offline

#283 Today 17:26:22

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

Re: Automatic thumbnails for Textpattern

Thank-you for the tips. but I still think something is counter intuitive. … at least to me

here is my images panel

I have a full size image id 16 which is 968 wide. I have a thumbnail image Custon which is 324 wide. in my images folder on the server there Is a 16t.png file that has a width of 324.

In specifying <txp:thumbnail id="16" /> I would expect that the resulting image would be displayed at 324 wide. But for me that was not the case. The image is output at even a larger width than 968 Adding width to the thumbnail code does nothing.

I wanted to use <txp:thumnial to output 6 different images at 324 wide. And to apply css to them.
I am obviously not getting the concept.
thanks.

I am now moving on to a custom blog section. …


…. texted postive

Offline

#284 Today 19:05:58

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

Re: Automatic thumbnails for Textpattern

bici wrote #342231:

The image is output at even a larger width than 968 Adding width to the thumbnail code does nothing.

Might it be css at work? What is the output image src (inspect in browser)?

Offline

#285 Today 19:24:33

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

Re: Automatic thumbnails for Textpattern

hmm. if I hand code the the html it works fine.

But using this code in my form results in large images:

<txp:thumbnail id="16" class="portfolio__nav__img" />

view source code:

  <!---  another option ================ -->
   <img src="https://textism.cal/images/16t.png" alt="" class="portfolio__nav__img" width="324" height="200">

and right-clicking on the large image shows the thumbnail at the correct size. 

I wont worry about this for now, but I just mention it  as I find it mysterious.

…. texted postive

Offline

Board footer

Powered by FluxBB