Php 是否配置Nginx以提供WEBP映像?
我正在使用ShortPixel创建名为image.WEBP的WEBP图像,这些图像保存在与image.jpg相同的文件夹中Php 是否配置Nginx以提供WEBP映像?,php,wordpress,nginx,server,webp,Php,Wordpress,Nginx,Server,Webp,我正在使用ShortPixel创建名为image.WEBP的WEBP图像,这些图像保存在与image.jpg相同的文件夹中 我在etc/nginx/conf.d/webp.conf中添加了这个: 并在nginx配置文件中添加了包含etc/nginx/conf.d/*.conf 在etc/nginx/conf.d/site.conf中添加了这个 使用nginx-t进行检查,一切正常。但是,在devtool/network选项卡中,图像仍然键入jpg。为什么呢 map $http_accept $w
包含etc/nginx/conf.d/*.conf
nginx-t
进行检查,一切正常。但是,在devtool/network选项卡中,图像仍然键入jpg。为什么呢
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
location ~* ^(/wp-content/.+)\.(png|jpe?g)$ {
set $base $1;
set $webp_uri $base$webp_suffix;
set $webp_old_uri $base.$2$webp_suffix;
set $root "FULL PATH OF wp-content PARENT";
root $root;
add_header Vary Accept;
if ( !-f $root$webp_uri ) {
add_header X_WebP_SP_Miss $root$webp_uri;
}
try_files $webp_uri $webp_old_uri $uri =404;
}