| | 247 | // Initial save of the new metadata. |
| | 248 | // At this point the file was uploaded and moved to the uploads directory |
| | 249 | // but the image sub-sizes haven't been created yet and the `sizes` array is empty. |
| | 250 | wp_update_attachment_metadata( $attachment_id, $image_meta ); |
| | 251 | |
| | 252 | $new_sizes = wp_get_registered_image_subsizes(); |
| | 253 | |
| | 254 | /** |
| | 255 | * Filters the image sizes automatically generated when uploading an image. |
| | 256 | * |
| | 257 | * @since 2.9.0 |
| | 258 | * @since 4.4.0 Added the `$image_meta` argument. |
| | 259 | * @since 5.3.0 Added the `$attachment_id` argument. |
| | 260 | * |
| | 261 | * @param array $new_sizes Associative array of image sizes to be created. |
| | 262 | * @param array $image_meta The image meta data: width, height, file, sizes, etc. |
| | 263 | * @param int $attachment_id The attachment post ID for the image. |
| | 264 | */ |
| | 265 | $new_sizes = apply_filters( 'intermediate_image_sizes_advanced', $new_sizes, $image_meta, $attachment_id ); |
| | 266 | |
| | 267 | $image_meta = _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ); |
| | 268 | |
| 338 | | // Initial save of the new metadata. |
| 339 | | // At this point the file was uploaded and moved to the uploads directory |
| 340 | | // but the image sub-sizes haven't been created yet and the `sizes` array is empty. |
| 341 | | wp_update_attachment_metadata( $attachment_id, $image_meta ); |
| 342 | | |
| 343 | | $new_sizes = wp_get_registered_image_subsizes(); |
| 344 | | |
| 345 | | /** |
| 346 | | * Filters the image sizes automatically generated when uploading an image. |
| 347 | | * |
| 348 | | * @since 2.9.0 |
| 349 | | * @since 4.4.0 Added the `$image_meta` argument. |
| 350 | | * @since 5.3.0 Added the `$attachment_id` argument. |
| 351 | | * |
| 352 | | * @param array $new_sizes Associative array of image sizes to be created. |
| 353 | | * @param array $image_meta The image meta data: width, height, file, sizes, etc. |
| 354 | | * @param int $attachment_id The attachment post ID for the image. |
| 355 | | */ |
| 356 | | $new_sizes = apply_filters( 'intermediate_image_sizes_advanced', $new_sizes, $image_meta, $attachment_id ); |
| 357 | | |
| 358 | | return _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ); |
| | 366 | return $image_meta; |