Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-04-29 14:44:57

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Crop and Resize Images on the fly in 2023 (or with PHP 8.1)

Some weeks ago I found this old article: https://textpattern.tips/crop-and-resize-images-on-the-fly and tried the latest available version of slir. It worked perfectly and I think it is great. Like that the person who is uploading images does not have to think about resizing or cropping anymore up front. Which for most people would be super helpful. Because using a grafic programm up front is just too much work.
The site I was testing it on ran on php 8.0.

When updating to php 8.1 it stopped working.

So a couple of things I would like to ask:

- The article is almost 15 years old. Is there any better/newer way to achieve what is done with slir? (I tried to find similar things on github or elsewhere but nothing seems to be that straight forward and easy to install)

- If you would consider this still a good way to go, I would try to find out where the problem with this tool is to run under PHP 8.1, whereas I have put it already through a syntax checker and did not find any problems.

- wouldn´t it be pretty cool to have something like that in a textpattern plugin? So that if wanted, sizes of images can be predefined in the template at the position where they appear and the server would generate and cache the image in the backround as needed?

Maybe I am not aware of something but IMHO this is very convenient for the person that is just maintaining the website. I know the plugin smd_thumbnail for example that would also generate physically different versions of an image by different profiles. I guess you could achieve the same with that. But an author would still have to play around with the profiles etc. to generate the right sizes. I think it would be better to set this up once in the template and the author is not involved.

Offline

#2 2023-04-29 15:04:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Crop and Resize Images on the fly in 2023 (or with PHP 8.1)

See this discussion and the latest image roadmap for more. But essentially, yes, the current thinking is to find a way to generate thumbs in the fly based on some settings that govern what sizes are permitted (so the URLs are not open to abuse).

Lots to work through yet. If you want to lend a hand, please add code and ideas to the images branch. Thank you.


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

#3 2023-04-29 15:11:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Crop and Resize Images on the fly in 2023 (or with PHP 8.1)

The smd_thumbnail approach is too limiting, imo. We need something to generate thumbs for use on the admin side and in image srcset/picture elements, which is more flexible than the rigid profile concept.


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

#4 2023-04-29 15:38:05

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: Crop and Resize Images on the fly in 2023 (or with PHP 8.1)

Ups! Very interesting. I was not aware of that discussion. And I am surprised (and happy) that it is happening so recently. Seems to quite nail the problem which I have right in front of me.

I am developing a site right now that is filled with quite some real content already, that is of “journalistic/magazine/news/blog/text+image” character. The site is online but not live.

Different people with basically zero CMS-skills and not necessarily with access to any image-software for pre-optimizing the images are going to maintain it. So this is a perfect testing environment for an approach with less options on the admin side and all pre-definition on the pages by the person (me) who is setting it up.

At least in that case for me it makes more sense to set image sizes up once and for all in the pages and not in the images panel. Once they are set, they will never be changed. Unless the website (and pages) is changed anyway.

The editor should not be the person who needs to think about the size or profile of the image he needs to use on which pages/positions. And the person who builds the site does not need textpatterns admin panel to define that.

Thank you for sharing the link. I will follow the discussion now more closely and hopefully I can add something benefital.

Last edited by demoncleaner (2023-04-29 15:43:47)

Offline

#5 2023-04-29 15:45:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Crop and Resize Images on the fly in 2023 (or with PHP 8.1)

Thank you. Please follow the image branch development and download it to test if you can. Also see issue 1472 which tracks the actual development progress. Lots of good info there and, although we’re currently evaluating Intervention, if a better (smaller, more powerful) library is out there, then we should try it out to see what it offers.


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

#6 2023-09-22 21:47:21

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 259
Website

Re: Crop and Resize Images on the fly in 2023 (or with PHP 8.1)

demoncleaner wrote #335373:

When updating to php 8.1 slir stopped working.

I have slir running under php 8.1 without any issues.

The trick is specifying a crop value whether you want cropping or not. eg.

<img src="/path/to/slir/w640-<txp:image_info type="w" />:<txp:image_info type="h" />/<txp:image_url />" alt />

If you don’t need cropping, modify slirrequest.class.php so that false is returned by the isCropping function .

Offline

#7 2023-09-23 06:14:27

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: Crop and Resize Images on the fly in 2023 (or with PHP 8.1)

Wow that are great news. Thanks a lot for sharing this. I will try it out. But I guess it should work if it works for you.
I am wondering if that changes anything about the thoughts we had on using slir in textpattern or maybe as a plugin.

Offline

Board footer

Powered by FluxBB