WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #47872, comment 32


Ignore:
Timestamp:
10/23/2019 01:52:25 PM (2 years ago)
Author:
GregLone
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #47872, comment 32

    initial v1  
    44For me, what differentiates new uploads from existing attachments:
    55- `wp_insert_attachment()` is called before, so the hook `add_attachment` is fired.
    6 - Or, the hook `wp_ajax_media_create_image_subsizes` is fired.
     6- Or, the hook `wp_ajax_media-create-image-subsizes` is fired.
    77In 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].
    88