Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2020-02-21 11:48:25

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,058
Website

Re: Custom thumbnail output

gaekwad wrote #321830:

The infamous Feature Creep Police are watching this thread, Bloke…

Comrade gaekwad, we are Present!


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

Offline

#14 2020-02-21 12:01:39

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

Re: Custom thumbnail output

Hehe, it won’t be 4.8.0. Gave it a quick test in a separate branch and it works, but there are issues with creating thumbnails with transparency in WebP, so we can do this later.


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

#15 2020-02-21 17:45:30

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Custom thumbnail output

phiw13 wrote #321834:

Comrade gaekwad, we are Present!

I love the smell of Communism in the morning.

Offline

#16 2020-02-21 20:18:05

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Custom thumbnail output

gaekwad wrote #321842:

I love the smell of Communism in the morning.

+1


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#17 2020-02-23 20:17:19

tka
New Member
Registered: 2010-02-15
Posts: 4

Re: Custom thumbnail output

Wow, didn’t expect to kick some discussion like this off. ;)

colak wrote #321820:

You can then call this form in your template by using <txp:output_form form="webp" /> or whatever else you may have called your form.

Thanks a bunch. Sounds like an excellent solution. Unfortunately it is not working in my case. I tested and it seems the processing steps right over the <txp:if_variable> (never enters the statement). So mabe, the txp:variable is not true in my case?

Btw: I am currently using v4.8.0-beta.2 – so maybe that’s a clue…

Offline

#18 2020-02-23 20:55:19

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: Custom thumbnail output

A

tka wrote #321857:

Unfortunately it is not working in my case. I tested and it seems the processing steps right over the <txp:if_variable> (never enters the statement).

Ah, there’s a mistake in the code above. You have to test for the variable colak’s called ai so it should read <txp:if_variable name="ai"> … like so:

<txp:variable name="ai"><txp:custom_field name="article_image" /></txp:variable>
<txp:if_variable name="ai">
<picture>
    <source srcset="/webp/<txp:variable name="ai" />.webp" type="image/webp">
    <source srcset="/images/<txp:variable name="ai" />.jpg" type="image/jpeg">
    <img src="/images/<txp:variable name="ai" />.jpg">
</picture>
</txp:if_variable>

The other provisos are that you have an image ID# entered in your article’s article image field and you have a webp image with the same {number}.webp filename in a separate /webp/ folder.


TXP Builders – finely-crafted code, design and txp

Offline

#19 2020-02-23 21:14:37

tka
New Member
Registered: 2010-02-15
Posts: 4

Re: Custom thumbnail output

Thanks, jakob. With the little tweak it works perfectly. :)

Seems like I can reduce my frontpage by about 200 KB with webp (for some users). Not much, but I guess some folks on mobile and limited data will enjoy.

Offline

Board footer

Powered by FluxBB