WordPress at Your Fingertips
function is not described

WP_Site_Icon::insert_attachment() public WP 4.3.0

Inserts an attachment.

{} It's a method of the class: WP_Site_Icon{}

Hooks from the method

Return

Int. Attachment ID

Usage

$WP_Site_Icon = new WP_Site_Icon();
$WP_Site_Icon->insert_attachment( $object, $file );
$object(array) (required)
Attachment object.
$file(string) (required)
File path of the attached image.

Changelog

Since 4.3.0 Introduced.

Code of WP_Site_Icon::insert_attachment() WP 5.8.2

public function insert_attachment( $object, $file ) {
	$attachment_id = wp_insert_attachment( $object, $file );
	$metadata      = wp_generate_attachment_metadata( $attachment_id, $file );

	/**
	 * Filters the site icon attachment metadata.
	 *
	 * @since 4.3.0
	 *
	 * @see wp_generate_attachment_metadata()
	 *
	 * @param array $metadata Attachment metadata.
	 */
	$metadata = apply_filters( 'site_icon_attachment_metadata', $metadata );
	wp_update_attachment_metadata( $attachment_id, $metadata );

	return $attachment_id;
}