webp_image plugin help

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

webp_image plugin help

Post 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
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3491
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: webp_image plugin help

Post 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.
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: webp_image plugin help

Post 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
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3491
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: webp_image plugin help

Post 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?
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: webp_image plugin help

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3491
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: webp_image plugin help

Post 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.
Post Reply

Return to “Modules/Add-Ons”