image_sideload_extensions
Filters the list of allowed file extensions when sideloading an image from a URL.
The default allowed extensions are:
- jpg
- jpeg
- jpe
- png
- gif
- webp
Использование
add_filter( 'image_sideload_extensions', 'wp_kama_image_sideload_extensions_filter', 10, 2 );
/**
* Function for `image_sideload_extensions` filter-hook.
*
* @param string[] $allowed_extensions Array of allowed file extensions.
* @param string $file The URL of the image to download.
*
* @return string[]
*/
function wp_kama_image_sideload_extensions_filter( $allowed_extensions, $file ){
// filter...
return $allowed_extensions;
}
- $allowed_extensions(string[])
- Array of allowed file extensions.
- $file(строка)
- The URL of the image to download.
Список изменений
| С версии 5.6.0 | Введена. |
| С версии 5.8.0 | Added 'webp' to the default list of allowed file extensions. |
Где вызывается хук
image_sideload_extensions
wp-admin/includes/media.php 1038
$allowed_extensions = apply_filters( 'image_sideload_extensions', $allowed_extensions, $file );