WP_Site_Icon::insert_attachment

Advertisement

Summery Summery

Inserts an attachment.

Syntax Syntax

WP_Site_Icon::insert_attachment( array $object, string $file )

Parameters Parameters

$object

(array) (Required) Attachment object.

$file

(string) (Required) File path of the attached image.

Return Return

(int) Attachment ID

Source Source

File: wp-admin/includes/class-wp-site-icon.php

	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;
	}

Advertisement

Changelog Changelog

Changelog
Version Description
4.3.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.