Release status: beta
|Description||Creates WebP versions of uploaded images|
|License||GNU General Public License 2.0 or later|
The WebP extension creates
.avif) versions of uploaded images and add them to the output by using Extension:PictureHtmlSupport.
This extension requires
libwebp to be installed on the server.
More information can be found in the Readme.
- Download, extract and place the file(s) in a directory called
- Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'WebP' );
- Configure as required.
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
If you wish to uninstall the extension remove the extension and delete the
// Enables WebP creation after a new image was uploaded $wgWebPEnableConvertOnUpload = true; // Enables WebP creation after a thumbnail was created $wgWebPEnableConvertOnTransform = true; // Compression quality of the image: 0 - 100 where 100 means most compressed $wgWebPCompressionQuality = 50; // the strength of the deblocking filter, between 0 (no filtering) and 100 (maximum filtering). A value of 0 turns off any filtering. Higher values increase the strength of the filtering process applied after decoding the image. The higher the value, the smoother the image appears. Typical values are usually in the range of 20 to 50. $wgWebPFilterStrength = 50; // when enabled, the algorithm spends additional time optimizing the filtering strength to reach a well-balanced quality. $wgWebPAutoFilter = true; // Create images through the JobQueue $wgWebPConvertInJobQueue = true; // Thumbnail Sizes to create through the maintenance script $wgWebPThumbSizes = [ 120, 320, 800, 1200, 1600 ]; // Enabling the Avif transformer (requries libheif and imagick >= 6.9) $wgEnabledTransformers = [ "MediaWiki\\Extension\\WebP\\Transformer\\WebPTransformer", "MediaWiki\\Extension\\WebP\\Transformer\\AvifTransformer", ];
A maintenance script exists to convert already uploaded images:
php extensions/WebP/maintenance/CreateFromLocalFiles.php # To only convert non-thumbnails run php extensions/WebP/maintenance/CreateFromLocalFiles.php --no-thumbs # To create thumbnails of custom sizes run # This will create two thumbnails with size 1000px and 1250px php extensions/WebP/maintenance/CreateFromLocalFiles.php --thumb-sizes=1000,1250 # To only work on some images run php extensions/WebP/maintenance/CreateFromLocalFiles.php --titles=ImageA.jpg,ImageB.png # To force the creation of already existing images run php extensions/WebP/maintenance/CreateFromLocalFiles.php --overwrite # Only work on page titles matching a prefix # Every page starting with prefix 'Example' will be selected php extensions/WebP/maintenance/CreateFromLocalFiles.php --title-prefix=Example # Only work on page titles matching a file-type # Every page starting with file-type 'png' will be selected # Can be combined with 'title-prefix' php extensions/WebP/maintenance/CreateFromLocalFiles.php --file-type=png
Images uploaded by URL won't generate webp version automatically.