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
webp_image plugin help
Re: webp_image plugin help
What is the output of ?
When you visit that exact url, does the plugin work for you?
BTW, I would expect that could be just replaced with {root_url} in this specific case.
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"}
Re: webp_image plugin help
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
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
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?
I mean what's outputted in the place where {webp_image ...} is used in the template?
Re: webp_image plugin help
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
The plugin code contains several checks for
Fetch requests don't have that value in the accept header.
The plugin then returns the url to the original image.
Code: Select all
strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false
The plugin then returns the url to the original image.