WP_Site_Icon::get_post_metadata( null|array|string $value, int $post_id, string $meta_key, bool $single ): array|null|string

In this article

Adds custom image sizes when meta data for an image is requested, that happens to be used as Site Icon.

Parameters

$valuenull|array|stringrequired
The value get_metadata() should return a single metadata value, or an array of values.
$post_idintrequired
Post ID.
$meta_keystringrequired
Meta key.
$singleboolrequired
Whether to return only the first value of the specified $meta_key.

Return

array|null|string The attachment metadata value, array of values, or null.

Source

public function get_post_metadata( $value, $post_id, $meta_key, $single ) {
	if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) {
		$site_icon_id = (int) get_option( 'site_icon' );

		if ( $post_id === $site_icon_id ) {
			add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) );
		}
	}

	return $value;
}

Changelog

VersionDescription
4.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.