Problem with Nginx WebP and srcset tag.
-
*Premise*
Hi guys, I have a vps with Debian 8, Nginx 1.6.2, ModSecurity, Page Speed, fail2ban, WordPress 4.6.1
As image plugins use EWWW Image Optimizer*Problem*
On nginx to show webp I followed this tutorial:
https://www.lazutkin.com/blog/2014/02/23/serve-files-with-nginx-conditionally/
Indeed, the images in “scr” tags are shown in webp, however in “srcset” tags are shown in their original format (.jpg .png etc ..).
I leave you an example link:
https://benessereesalute.org/2016/08/test-paginazione-3/
As you see in the image source, in the “src” tag it is webp but I have problems with “srcset”.
I don’t want to remove this new WordPress tag, I would look for a solution because in Apache with .htaccess works. On nginx I can not find an alternative.Apache .htaccess works:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond% {} HTTP_ACCEPT image / webp RewriteCond% {REQUEST_FILENAME} (. *) \. (Jpe? G | png) $ REQUEST_FILENAME RewriteCond% {} \. Webp -f RewriteRule (. +) \. (Jpe? G | png) $% {} REQUEST_FILENAME .webp [T = image / webp, E = accept: 1] </ IfModule> <IfModule mod_headers.c> Header append Vary Accept env = REDIRECT_accept </ IfModule> AddType image / webp .webp
Ideas?
- The topic ‘Problem with Nginx WebP and srcset tag.’ is closed to new replies.