Code Duplication    Length = 18-19 lines in 2 locations

wp-admin/custom-header.php 1 location

@@ 1155-1172 (lines=18) @@
1152
	 *
1153
	 * @return array Attachment object.
1154
	 */
1155
	final public function create_attachment_object( $cropped, $parent_attachment_id ) {
1156
		$parent = get_post( $parent_attachment_id );
1157
		$parent_url = wp_get_attachment_url( $parent->ID );
1158
		$url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
1159
1160
		$size = @getimagesize( $cropped );
1161
		$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
1162
1163
		$object = array(
1164
			'ID' => $parent_attachment_id,
1165
			'post_title' => basename($cropped),
1166
			'post_mime_type' => $image_type,
1167
			'guid' => $url,
1168
			'context' => 'custom-header'
1169
		);
1170
1171
		return $object;
1172
	}
1173
1174
	/**
1175
	 * Insert an attachment and its metadata.

wp-admin/includes/class-wp-site-icon.php 1 location

@@ 89-107 (lines=19) @@
86
	 * @param int    $parent_attachment_id Attachment ID of parent image.
87
	 * @return array Attachment object.
88
	 */
89
	public function create_attachment_object( $cropped, $parent_attachment_id ) {
90
		$parent     = get_post( $parent_attachment_id );
91
		$parent_url = wp_get_attachment_url( $parent->ID );
92
		$url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
93
94
		$size       = @getimagesize( $cropped );
95
		$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
96
97
		$object = array(
98
			'ID'             => $parent_attachment_id,
99
			'post_title'     => basename( $cropped ),
100
			'post_content'   => $url,
101
			'post_mime_type' => $image_type,
102
			'guid'           => $url,
103
			'context'        => 'site-icon'
104
		);
105
106
		return $object;
107
	}
108
109
	/**
110
	 * Inserts an attachment.