wppaste
WordPress

Custom_Image_Header::create_attachment_object( string $cropped, int $parent_attachment_id ): array

Since
3.9.0
Source
wp-admin/includes/class-custom-image-header.php:1323
Creates an attachment 'object'.

Parameters

$croppedstring
Cropped image URL.
$parent_attachment_idint
Attachment ID of parent image.

Return

array
An array with attachment object data.

Uses · 5

Source

	final public function create_attachment_object( $cropped, $parent_attachment_id ) {		_deprecated_function( __METHOD__, '6.5.0', 'wp_copy_parent_attachment_properties()' );		$parent     = get_post( $parent_attachment_id );		$parent_url = wp_get_attachment_url( $parent->ID );		$url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url ); 		$size       = wp_getimagesize( $cropped );		$image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; 		$attachment = array(			'ID'             => $parent_attachment_id,			'post_title'     => wp_basename( $cropped ),			'post_mime_type' => $image_type,			'guid'           => $url,			'context'        => 'custom-header',			'post_parent'    => $parent_attachment_id,		); 		return $attachment;	}

History

Introduced in 3.9.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.5.0
Deprecated.from the docblock
3.9.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/class-custom-image-header.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.