WP_Site_Icon::create_attachment_object( string $cropped, int $parent_attachment_id )

Creates an attachment ‘object’.


Parameters

$cropped

(Required) Cropped image URL.

$parent_attachment_id

(Required) Attachment ID of parent image.


Return

(array) Attachment object.


Source

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

	public function create_attachment_object( $cropped, $parent_attachment_id ) {
		$parent     = get_post( $parent_attachment_id );
		$parent_url = wp_get_attachment_url( $parent->ID );
		$url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );

		$size       = @getimagesize( $cropped );
		$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';

		$object = array(
			'ID'             => $parent_attachment_id,
			'post_title'     => basename( $cropped ),
			'post_content'   => $url,
			'post_mime_type' => $image_type,
			'guid'           => $url,
			'context'        => 'site-icon'
		);

		return $object;
	}


Changelog

Changelog
Version Description
WP-4.3.0 Introduced.