@@ 1182-1197 (lines=16) @@ | ||
1179 | * |
|
1180 | * @return int Attachment ID. |
|
1181 | */ |
|
1182 | final public function insert_attachment( $object, $cropped ) { |
|
1183 | $attachment_id = wp_insert_attachment( $object, $cropped ); |
|
1184 | $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); |
|
1185 | /** |
|
1186 | * Filters the header image attachment metadata. |
|
1187 | * |
|
1188 | * @since 3.9.0 |
|
1189 | * |
|
1190 | * @see wp_generate_attachment_metadata() |
|
1191 | * |
|
1192 | * @param array $metadata Attachment metadata. |
|
1193 | */ |
|
1194 | $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata ); |
|
1195 | wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
1196 | return $attachment_id; |
|
1197 | } |
|
1198 | ||
1199 | /** |
|
1200 | * Gets attachment uploaded by Media Manager, crops it, then saves it as a |
@@ 119-136 (lines=18) @@ | ||
116 | * @param string $file File path of the attached image. |
|
117 | * @return int Attachment ID |
|
118 | */ |
|
119 | public function insert_attachment( $object, $file ) { |
|
120 | $attachment_id = wp_insert_attachment( $object, $file ); |
|
121 | $metadata = wp_generate_attachment_metadata( $attachment_id, $file ); |
|
122 | ||
123 | /** |
|
124 | * Filters the site icon attachment metadata. |
|
125 | * |
|
126 | * @since 4.3.0 |
|
127 | * |
|
128 | * @see wp_generate_attachment_metadata() |
|
129 | * |
|
130 | * @param array $metadata Attachment metadata. |
|
131 | */ |
|
132 | $metadata = apply_filters( 'site_icon_attachment_metadata', $metadata ); |
|
133 | wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
134 | ||
135 | return $attachment_id; |
|
136 | } |
|
137 | ||
138 | /** |
|
139 | * Adds additional sizes to be made when creating the site_icon images. |