wpseek.com
A WordPress-centric search engine for devs and theme authors



_wp_filter_image_sizes_additional_mime_type_support › WordPress Function

Since6.1.0
Deprecatedn/a
_wp_filter_image_sizes_additional_mime_type_support ( $sizes, $attachment_id )
Parameters: (2)
  • (array) $sizes Associative array of image sizes.
    Required: Yes
  • (int) $attachment_id Attachment ID.
    Required: Yes
Returns:
  • (array) $sizes Filtered $sizes with only those that support secondary mime type output.
Defined at:
Codex:

Filters the list of image size objects that support secondary mime type output.



Source

function _wp_filter_image_sizes_additional_mime_type_support( $sizes, $attachment_id ) {

	// Include only the core sizes that do not rely on add_image_size(). Additional image sizes are opt-in.
	$enabled_sizes = array(
		'thumbnail'      => true,
		'medium'         => true,
		'medium_large'   => true,
		'large'          => true,
		'post-thumbnail' => true,
	);

	/**
	 * Filter the sizes that support secondary mime type output. Developers can use this
	 * to control the output of additional mime type sub-sized images.
	 *
	 * @since 6.1.0
	 *
	 * @param array $enabled_sizes Map of size names and whether they support secondary mime type output.
	 * @param int   $attachment_id Attachment ID.
	 */
	$enabled_sizes = apply_filters( 'wp_image_sizes_with_additional_mime_type_support', $enabled_sizes, $attachment_id );

	// Filter supported sizes to only include enabled sizes.
	return array_intersect_key( $sizes, array_filter( $enabled_sizes ) );
}