Title: Images to AVIF
Author: kubiq
Published: <strong>2026 年 1 月 13 日</strong>
Last modified: 2026 年 9 月 17 日

---

搜索插件

![](https://ps.w.org/images-to-avif/assets/banner-772x250.png?rev=3438659)

![](https://ps.w.org/images-to-avif/assets/icon-256x256.png?rev=3438659)

# Images to AVIF

 作者：[kubiq](https://profiles.wordpress.org/kubiq/)

[下载](https://downloads.wordpress.org/plugin/images-to-avif.2.0.zip)

 * [详情](https://cn.wordpress.org/plugins/images-to-avif/#description)
 * [评价](https://cn.wordpress.org/plugins/images-to-avif/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/images-to-avif/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/images-to-avif/#developers)

 [支持](https://wordpress.org/support/plugin/images-to-avif/)

## 描述

Statistics say that AVIF format can save more than a half of the page weight without
losing images quality.
 Convert PNG, JPG, GIF and WEBP images to AVIF and speed 
up your web, save visitors download data, make your Google ranking better. Install
also Images to WebP plugin if you want to have fallback to WebP and then to the 
original file.

 * **automated test after plugin activation to make sure it will work on your server**
 * **works with all types of WordPress installations: domain, subdomain, subdirectory,
   multisite/network**
 * **works on Apache and NGiNX**
 * **image URL will be not changed** so it works everywhere, in <img> src, srcset,
   <picture>, even in CSS backgrounds and there is no problem with cache
 * **original files will be not touched**
 * set quality of converted images
 * auto convert on upload
 * only convert image if AVIF filesize is lower than original image filesize
 * bulk convert existing images to AVIF ( you can choose folders )
 * bulk convert only missing images

### Hooks for developers

#### images_to_avif_sizes

Maybe you want to disable AVIF for thumbnails

    ```
    add_filter( 'images_to_avif_sizes', 'disable_images_to_avif_sizes', 10, 2 );
    function disable_images_to_avif_sizes( $sizes, $attachmentId ){
        unset( $sizes['thumbnail'] );
        return $sizes;
    }
    ```

#### images_to_avif_htaccess

Maybe you want to modify htaccess rules somehow

    ```
    add_filter( 'images_to_avif_htaccess', 'modify_images_to_avif_htaccess', 10, 2 );
    function modify_images_to_avif_htaccess( $rewrite_rules ){
        // do some magic here
        return $rewrite_rules;
    }
    ```

#### images_to_avif_abspath

Maybe you use roots.io/bedrock or other custom folder structure

    ```
    add_filter( 'images_to_avif_abspath', 'modify_images_to_avif_abspath', 10, 2 );
    function modify_images_to_avif_abspath( $abspath ){
        return trailingslashit( WP_CONTENT_DIR );
    }
    ```

#### $images_to_avif->convert_image()

Maybe you want to automatically generate AVIF for other plugins

    ```
    add_action( 'XXPLUGIN_image_created', 'XX_images_to_avif', 10, 2 );
    function XX_images_to_avif( $image_path ){
        global $images_to_avif;
        $images_to_avif->convert_image( $image_path );
    }
    ```

## 屏幕截图

[[

[[

[[

## 安装

 1. Upload `images-to-avif` directory to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

## 常见问题

### Plugin requirements

It should work almost everywhere 😉
 PHP 5.6 or higher GD or Imagick extension with
AVIF support Enabled server modules: `mod_mime`, `mod_rewrite`

### AVIF images stored location

AVIF images are generated in same directory as original image. Example:
 original
img: `/wp-content/uploads/2019/11/car.png` avif version: `/wp-content/uploads/2019/
11/car.png.avif`

### How to get original image from the browser?

Just add `?no_avif=1` to the URL and original JPG/PNG will be loaded

### How to check if plugin works?

When you have installed plugin and converted all images, follow these steps:

 1. Run `Google Chrome` and enable `Dev Tools` (F12).
 2. Go to the `Network` tab click on `Disable cache` and select filtering for `Img`_(
    Images)_.
 3. Refresh your website page.
 4. Check list of loaded images. Note `Type` column.
 5. If value of `avif` is there, then everything works fine.

### NGiNX and Apache together

If you have some proxy setup or some other combination of NGiNX and Apache on your
server, then probably .htaccess changes won’t work and you will need to ask your
hosting provider to disable NGiNX direct processing of image static files.

### Apache .htaccess

Plugin should automatically update your .htaccess with needed rules.
 In case it’s
not possible to write them automatically, screen with instructions will appear. 
Anyway, here is how it should look like:

    ```
    <IfModule mod_mime.c>
        AddType image/avif .avif
    </IfModule>

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_ACCEPT} image/avif
        RewriteCond %{REQUEST_FILENAME} "/"
        RewriteCond %{REQUEST_FILENAME} "\.(jpg|jpeg|png|gif|webp)$"
        RewriteCond %{REQUEST_FILENAME}\.avif -f
        RewriteCond %{QUERY_STRING} !no_avif
        RewriteRule ^(.+)$ $1\.avif [NC,T=image/avif,E=avif,L]
    </IfModule>
    ```

### NGiNX config

After you activate plugin, screen with instructions will appear.
 Anyway, here is
how it should look like:

You need to add this map directive to your http config, usually nginx.conf ( inside
of the http{} section ):

    ```
    map $arg_no_avif $no_avif{
        default "";
        "1" "no_avif";
    }

    map $http_accept $avif_suffix{
        default "";
        "~*avif" ".avif";
    }
    ```

or without `map` directive:

    ```
    if ( $http_accept ~ "image/avif" ) {
        set $avif .avif ;
    }

    location ~* (.*)\.(?:png|jpe?g|gif|webp)$ {
        if ( -f $document_root$1.avif ) {
                set $avif serve$avif ;
        }
        if ( $avif = "serve.avif" ) {
            return 301 '$1.avif';
        }
    }
    ```

then you need to add this to your server block, usually site.conf or /nginx/sites-
enabled/default ( inside of the server{} section ):

    ```
    location ~* ^/.+\.(png|gif|webp|jpe?g)$ {
        add_header Vary Accept;
        try_files $uri$avif_suffix$no_avif $uri =404;
    }
    ```

### ISP Manager

Are you using ISP Manager? Then it’s probably not working for you, but no worries,
you just need to go to `WWW domains` and delete `jpg|jpeg|png` from the `Static 
content extensions` field.

### Delete all generated AVIF images

There is no button to do that and it will also not delete generated AVIFs automatically
when you deactivate the plugin, but if you really need this, you can run some shell
command to achieve this:

    ```
    find . -type f -name "*.avif" -exec bash -c 'if [ -f "${1%.avif}" ]; then echo "Deleting $1"; rm "$1"; fi' _ {} \;
    ```

This will find all the files with a `.avif` extension and if there is similar file
with the exact filename, but without the `.avif` extension, then it will delete 
it.

### .htaccess in /uploads/ folder

Sometimes you may have an .htaccess file in your /uploads/ folder and if it contains
RewriteRules it can break this plugin functionality and you will need to add `RewriteOptions
InheritBefore` before your RewriteRules

## 评价

此插件暂无评价。

## 贡献者及开发者

「Images to AVIF」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ kubiq ](https://profiles.wordpress.org/kubiq/)

[帮助将「Images to AVIF」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/images-to-avif)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/images-to-avif/)，查看
[SVN仓库](https://plugins.svn.wordpress.org/images-to-avif/)，或通过[RSS](https://plugins.trac.wordpress.org/log/images-to-avif/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/images-to-avif/)。

## 更新日志

#### 2.0

 * now images are optimized in the background instead of during upload which was
   slowing down the workflow
 * fix a few small things based on the current Plugin Check results

#### 1.1

 * optimize old images convert process
 * remove not working images_to_avif_extensions filter

#### 1.0

 * First version

## 额外信息

 *  版本 **2.0**
 *  最后更新：**2 月前**
 *  活跃安装数量 **100+**
 *  WordPress 版本 ** 5.0 或更高版本 **
 *  已测试的最高版本为 **6.9.11**
 *  PHP 版本 ** 7.0 或更高版本 **
 *  语言
 * [English (US)](https://wordpress.org/plugins/images-to-avif/)
 * 标签
 * [convert](https://cn.wordpress.org/plugins/tags/convert/)[media](https://cn.wordpress.org/plugins/tags/media/)
   [Optimize](https://cn.wordpress.org/plugins/tags/optimize/)[pictures](https://cn.wordpress.org/plugins/tags/pictures/)
 *  [高级视图](https://cn.wordpress.org/plugins/images-to-avif/advanced/)

## 评级

尚未提交反馈。

[您的评价](https://wordpress.org/support/plugin/images-to-avif/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/images-to-avif/reviews/)

## 贡献者

 *   [ kubiq ](https://profiles.wordpress.org/kubiq/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/images-to-avif/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](https://www.paypal.me/jakubnovaksl)