Enable WebP images in WooCommerce
WebP files should be able to be imported in WooCommerce, as they've been supported in WordPress core since v5.8. Adding this pull request, based on the following comments: - https://github.com/woocommerce/woocommerce/issues/28998#issuecomment-1131525719 - https://github.com/woocommerce/woocommerce/issues/28998#issuecomment-1128403295 This is a first for me, hope all is in order. Cheers! 🙂
This commit is contained in:
parent
38822cb3e9
commit
0661e1c2a8
|
@ -2583,3 +2583,30 @@ function wc_cache_get_multiple( $keys, $group = '', $force = false ) {
|
|||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable WebP images in WooCommerce.
|
||||
*
|
||||
* WebP files should be able to be imported in WooCommerce, as they've been supported in WordPress core since v5.8.
|
||||
*/
|
||||
add_filter( 'woocommerce_rest_allowed_image_mime_types', 'more_mimes_to_exts' );
|
||||
function more_mimes_to_exts( $mime_to_ext ){
|
||||
$mime_to_ext['webp'] = 'image/webp';
|
||||
|
||||
return $mime_to_ext;
|
||||
}
|
||||
|
||||
function wc_rest_allowed_image_mime_types() {
|
||||
return apply_filters(
|
||||
'woocommerce_rest_allowed_image_mime_types',
|
||||
array(
|
||||
'jpg|jpeg|jpe' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'png' => 'image/png',
|
||||
'bmp' => 'image/bmp',
|
||||
'tiff|tif' => 'image/tiff',
|
||||
'ico' => 'image/x-icon',
|
||||
'webp' => 'image/webp',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue