@@ 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. |
@@ 1186-1201 (lines=16) @@ | ||
1183 | * @param string $cropped Cropped image URL. |
|
1184 | * @return int Attachment ID. |
|
1185 | */ |
|
1186 | final public function insert_attachment( $object, $cropped ) { |
|
1187 | $attachment_id = wp_insert_attachment( $object, $cropped ); |
|
1188 | $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); |
|
1189 | /** |
|
1190 | * Filters the header image attachment metadata. |
|
1191 | * |
|
1192 | * @since 3.9.0 |
|
1193 | * |
|
1194 | * @see wp_generate_attachment_metadata() |
|
1195 | * |
|
1196 | * @param array $metadata Attachment metadata. |
|
1197 | */ |
|
1198 | $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata ); |
|
1199 | wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
1200 | return $attachment_id; |
|
1201 | } |
|
1202 | ||
1203 | /** |
|
1204 | * Gets attachment uploaded by Media Manager, crops it, then saves it as a |