Adds additional sizes to be made when creating the site icon images.
Parameters
$sizes
array[]optional- Array of arrays containing information for additional sizes.
Default:
array()
Source
public function additional_sizes( $sizes = array() ) {
$only_crop_sizes = array();
/**
* Filters the different dimensions that a site icon is saved in.
*
* @since 4.3.0
*
* @param int[] $site_icon_sizes Array of sizes available for the Site Icon.
*/
$this->site_icon_sizes = apply_filters( 'site_icon_image_sizes', $this->site_icon_sizes );
// Use a natural sort of numbers.
natsort( $this->site_icon_sizes );
$this->site_icon_sizes = array_reverse( $this->site_icon_sizes );
// Ensure that we only resize the image into sizes that allow cropping.
foreach ( $sizes as $name => $size_array ) {
if ( isset( $size_array['crop'] ) ) {
$only_crop_sizes[ $name ] = $size_array;
}
}
foreach ( $this->site_icon_sizes as $size ) {
if ( $size < $this->min_size ) {
$only_crop_sizes[ 'site_icon-' . $size ] = array(
'width ' => $size,
'height' => $size,
'crop' => true,
);
}
}
return $only_crop_sizes;
}
Hooks
- apply_filters( ‘site_icon_image_sizes’,
int[] $site_icon_sizes ) Filters the different dimensions that a site icon is saved in.
Changelog
Version | Description |
---|---|
4.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.