[wp-trac] [WordPress Trac] #47872: Try to create image sub-sizes again when uploading fails with a PHP fatal error
WordPress Trac
noreply at wordpress.org
Tue Oct 22 21:59:35 UTC 2019
#47872: Try to create image sub-sizes again when uploading fails with a PHP fatal
error
-------------------------------------------------+-------------------------
Reporter: azaozz | Owner: azaozz
Type: enhancement | Status: closed
Priority: high | Milestone: 5.3
Component: Upload | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch needs-testing has- | Focuses:
screenshots close has-dev-note |
-------------------------------------------------+-------------------------
Comment (by GregLone):
Indeed, I don't see any way to pass a context to this hook.
By the way, I'm mixing #40439 and this ticket here, tell me if I'm not at
the right place to discuss this.
For me, what differentiates new uploads from existing attachments:
- `wp_insert_attachment()` is called before, so the hook `add_attachment`
is fired.
- Or, the hook `wp_ajax_media_create_image_subsizes` is fired.
In both cases we (as in "third party plugins", not WP core) can use the
fired hook to store the attachment ID, and use it later in the new hook
for comparison. It's a bit tricky, not clean, but it works (at least for
`add_attachment` so far). This is actually [https://github.com/wp-media
/imagify-plugin/blob/master/inc/classes/class-imagify-auto-
optimization.php what I do in Imagify].
Since I use `updated_post_meta/added_post_meta` to trigger what I want to
do (automatic optimization of the images) (so I'm sure the post meta value
is up-to-date in the DB), it became more difficult to [https://github.com
/wp-media/imagify-plugin/blob/improvement/compat-wp53-save-progress-
upload/inc/classes/class-imagify-auto-optimization.php#L66-L67 trigger
only when all is done], and not for each size.
I see that both `wp_create_image_subsizes()` and
`wp_update_image_subsizes()` use `_wp_make_subsizes()`, why not adding
this hook at the end of it?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47872#comment:32>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list