Page 1 of 1

webp_image plugin help

Posted: Thu Nov 30, 2023 10:32 am
by WDJames
Hello all,

We are using LISE to display resources on a page. There are a lot of resources so we ended up using javascript fetch to load the resources after the page is loaded:

<__script__>
document.addEventListener('DOMContentLoaded', function() {
let url = '{cms_selflink page="$page_alias" urlonly="true"}?mact=LISEResources,cntnt01,default,0&showtemplate=false'

fetch(url)

</__script>

Each resource has an image so we are using the webp_image plugin to reduce the image file size. The odd thing is that the plugin doesn't execute on the page (when loaded via fetch) but it does when you visit the url itself. Is there a way to execute the plugin when using fetch?

Thanks in advance for your help.

James

Re: webp_image plugin help

Posted: Thu Nov 30, 2023 11:51 am
by velden
What is the output of

Code: Select all

{cms_selflink page="$page_alias" urlonly="true"}?mact=LISEResources,cntnt01,default,0&showtemplate=false
?
When you visit that exact url, does the plugin work for you?

BTW, I would expect that

Code: Select all

{cms_selflink page="$page_alias" urlonly="true"}
could be just replaced with {root_url} in this specific case.

Re: webp_image plugin help

Posted: Thu Nov 30, 2023 12:38 pm
by WDJames
Hi Velden,

The output of that code is the url of the page plus the query parameters:

https://website.com/resources?mact=LISEResources,cntnt01,default,0&showtemplate=false

Yes, when I visit the URL the plugin works which is why I'm not sure why it wouldn't work when loaded via fetch. Also, within the LISE template I am using the {MleCMS action=init} tag which works and adds confusion as to why the webp_image plugin isn't working.

Thanks,

James

Re: webp_image plugin help

Posted: Thu Nov 30, 2023 1:27 pm
by velden
And what is the output you get from while fetching the url w.r.t. the plugin?
I mean what's outputted in the place where {webp_image ...} is used in the template?

Re: webp_image plugin help

Posted: Thu Nov 30, 2023 2:08 pm
by WDJames
The output of the tag (via fetch) is the original image URL but when the tag is used on a regular page, it returns the url of a .webp image.

Re: webp_image plugin help

Posted: Thu Nov 30, 2023 3:18 pm
by velden
The plugin code contains several checks for

Code: Select all

strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false
Fetch requests don't have that value in the accept header.

The plugin then returns the url to the original image.