Which WordPress hooks fire when the FeedSync Companion imports a listing photo (for WebP conversion or image optimisers)?

The Companion uses WordPress's own attachment functions, so the standard core hooks fire. It has no action of its own after a photo is added.

  1. It downloads the photo with download_url() and registers it with wp_insert_attachment(): add_attachment fires here, with the file in place but no metadata yet.
  2. Image sizes are made with wp_generate_attachment_metadata(): the wp_generate_attachment_metadata filter fires here (plus intermediate_image_sizes_advanced and big_image_size_threshold). With the default Image Size Generation setting (Queue for Later Processing, under FeedSync › Settings › Images) this happens afterwards, in a queued job; Generate Immediately does it straight after the download. This is the best place for a WebP conversion.
  3. A photo that changes in the CRM is replaced in the same attachment (update_attached_file fires).

It doesn't use media_handle_sideload(), so wp_handle_upload / wp_handle_sideload and their prefilters don't fire.

Create the WebP alongside the original, don't replace it. The Companion makes image sizes from the original file, and when it regenerates sizes it removes files the attachment's metadata no longer lists. A converter that renames or removes the original can leave a photo without its sizes. A .webp or .avif saved beside the original (photo.jpg.webp or photo.webp) is fine: the orphaned-files check in FeedSync › Tools treats it as in use.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.