wordpress 插件 Converter for Media 如何使用
1、基础版 Converter for Media 可以使用 .webp 格式 这个格式也挺好了
2、pro版本 Converter for Media 可以使用.AVIF 格式,这个格式是下一代图片格式 目前最强 ,但是要买pro
3、安装基础版 Converter for Media ,需要配置 apache 或者 nginx 环境 ,配置nginx 环境复杂一点,插件有详细说明
# BEGIN Converter for Media set $ext_avif ".avif"; if ($http_accept !~* "image/avif") { set $ext_avif ""; } set $ext_webp ".webp"; if ($http_accept !~* "image/webp") { set $ext_webp ""; } location ~* ^/wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif)$ { add_header Vary Accept; add_header Cache-Control "private"; expires 365d; try_files /wp-content/uploads-webpc/$path.$ext$ext_avif /wp-content/uploads-webpc/$path.$ext$ext_webp $uri =404; } # END Converter for Media这是nginx 主要配置代码
官网使用说明:Configuration for Nginx server - matt plugins https://mattplugins.com/docs/nginx-configuration
检测是否生效官网说明:如何检查“媒体转换器”插件是否正常工作?- 哑光插件
https://mattplugins.com/docs/how-to-test-converter-for-media-plugin
这个Type 是重点,有好多人认为img 的.jpg 还是原来的认为没有生效,其实不是这样的,Converter for Media 插件会生成一个 upload-webpc 文件夹 (我用的基础版所以只有webpc),配置文件把文件url 指引到原图片url ,所以当看到 network里 图片的 Type 是 webp或者 avif 就证明插件生效了。
