Code Duplication    Length = 18-19 lines in 2 locations

src/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.

src/wp-admin/custom-header.php 1 location

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