Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 是否配置Nginx以提供WEBP映像?_Php_Wordpress_Nginx_Server_Webp - Fatal编程技术网

Php 是否配置Nginx以提供WEBP映像?

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

我正在使用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 $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;
    }