Jump to content

WEBP-first strategy hook not working after size()


elabx
 Share

Recommended Posts

Ok so just stumbled into a website using Clouflare and the plain htaccess method doesn't seem to kick in, tried altering the url() method with a hook but stumbled back into the problem problem where it doesn't seem to work after applying size(). Anybody has some info on this?

if($page->template != 'admin') {
    $wire->addHookAfter('Pageimage::url', function($event) {
        static $n = 0;
        $n = ++$n;
        if($n === 1){
            $event->return = $event->object->webp()->url();
        }
        $n--;
    });
}

 

Link to comment
Share on other sites

Ok... that's tough than.

I changed one of my sites (behind Cloudflares Free Plan) to strategy 1 as described here: https://processwire.com/blog/posts/webp-images-and-more/#strategy-1-automatically-delivering-webp-for-jpg-png-images

It works, even in image URLs generated with size().

Ryan says this in the article:

Quote

These rewrite rules will need adjustment if you are using $config->pagefileExtendedPaths (though I don’t think many are using that option).

Maybe that's the reason.

Link to comment
Share on other sites

58 minutes ago, wbmnfktr said:

I changed one of my sites (behind Cloudflares Free Plan) to strategy 1 as described here: https://processwire.com/blog/posts/webp-images-and-more/#strategy-1-automatically-delivering-webp-for-jpg-png-images

This is my "go to" approach but susprisingly it didn't work out as expected. It just delivers the normal jpg image it's as if it's not redirecting the webp header or something, that's why I decided to switch to the extension hook but then I stumbled into this. Maybe I should open a github issue?

Link to comment
Share on other sites

I guess it's still too early for an issue response on Github.

Let's compare the things we can compare:

  • ProcessWire 3.0.132
  • PHP 7.2
  • Cloudflare Free Plan (default settings)
  • webP Strategy 1
  • htaccess: non-www Redirect
  • htaccess: https Redirect
  • pagefileExtendedPaths NOT set

2019-09-18-165025_873x400_scrot.png.bb691f80b76994474231cadc7d1b68d6.png

As you don't have access to the Cloudflare settings... is there someone who can look into it? Maybe they use a load balancer, built in whatever. Maybe the site is still cached. Cloudflare CDN is sometimes bit of a PITA. Dev-Mode or DNS-by-pass would be nice to test out. Maybe there are even custom page rules that are image related. There is a lot of stuff someone can do there.

Link to comment
Share on other sites

  • 2 weeks later...

Hu @wbmnfktr!!

Your post just made me realize, I'm using Runcloud so I have nginx in front of Apache, and just tested another site that is not using cloudflare and same issue, webp is not being delivered. So maybe that could be it? Cause i remember the http-to-https redirect had an issue, so i had to use a special one. 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...