image_sideload_extensions filter-hookWP 5.6.0

Filters the list of allowed file extensions when sideloading an image from a URL.

The default allowed extensions are:

  • jpg
  • jpeg
  • jpe
  • png
  • gif

Usage

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(string)
The URL of the image to download.

Changelog

Since 5.6.0 Introduced.

Where the hook is called

media_sideload_image()
image_sideload_extensions
wp-admin/includes/media.php 1021
$allowed_extensions = apply_filters( 'image_sideload_extensions', $allowed_extensions, $file );

Where the hook is used in WordPress

Usage not found.