hmmmmm? I got a quick idea you could try though
first of all you must generate the avif file somehow , since our plugin does not provide such feature
after that, the plugin has an API to modify the output after its modification and before send to browser , in where you can run some check and replace , e.g.
function remove_broken_style( $content ) {
/*
grab and generate a list of image inside of $content
check if such image has avif file availeble , if so , replace the image URI , e.g from /wp-content/uploads/2023/06/08/something.jpg to /wp-contnt/uploads/2023/06/08/something.avif
then return $content
*/
return $content ;
}
add_filter( 'litespeed_buffer_after', 'remove_broken_style', 0);
or another dirty workaround I used before through .htaccess rewrite rule , for webp replacement on some loading method plugin does not support
RewriteCond %{HTTP_ACCEPT} "image/avif"
RewriteCond %{REQUEST_FILENAME}.avif -f
RewriteRule ^(.*).(jpg|jpeg|png|gif) $1.$2.avif [T=image/avif,L]
this will check each request to webserver on its accept header, if it supports avif , and something.jpg.avif
exists , then rewrite the URI to something.jpg.avif
with force content type to image/avif
, this does NOT change URI in browser, but under the hood it loads as image/avif
with smaller size
the rewrite rule way will break with some CDN caching if it doesn’t support vary on accept