Files
h4b-image-optim/h4b-image-optim.php
Henk 868dbe0ff4 fix: avif tracking + new generate-missing-siblings command (v0.2.1)
Two related fixes to the AVIF pipeline:

Fix #1 — postmeta tracking
  Format_Generator::process_avif_job() now updates _h4b_img_optim's
  avif_status from 'queued' → 'done' (with byte size) or 'error' (with
  reason) after the cron job runs. Previously the postmeta said
  'queued' forever even when AVIF files existed on disk.

Fix #2 — root cause of missing AVIFs on rds.ink bulk run
  wp_schedule_single_event(time()+30, …) coalesces identical args at
  the same timestamp, so bulk-queueing hundreds of AVIF jobs in the
  same second silently dropped many. Added wp h4b-img generate-missing-siblings
  that walks attachment metadata, finds files missing .webp/.avif, and
  generates them SYNCHRONOUSLY (no queue, no coalescing). Only processes
  registered sizes by default; --include-orphans flag for disk-walk mode.

Verified on prod rds.ink: 1,134 of 1,737 registered images >=20KB have
AVIF, 603 are missing. Of 389 orphan files >=20KB missing AVIF, those
aren't referenced from any post/postmeta — correctly excluded.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 14:52:50 +10:00

29 lines
975 B
PHP

<?php
/**
* Plugin Name: H4B Image Optim
* Plugin URI: https://gitea.help4bis.com/help4bis/h4b-image-optim
* Description: ICC-safe image optimisation with WebP + AVIF generation. Replaces Smush Pro without the grey-wash bug. No CDN.
* Version: 0.2.1
* Author: help4bis (Henk + Claude)
* Author URI: https://help4bis.com
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Requires PHP: 8.1
* Requires at least: 6.4
* Text Domain: h4b-image-optim
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'H4B_IMG_OPTIM_VERSION', '0.2.1' );
define( 'H4B_IMG_OPTIM_FILE', __FILE__ );
define( 'H4B_IMG_OPTIM_DIR', plugin_dir_path( __FILE__ ) );
define( 'H4B_IMG_OPTIM_URL', plugin_dir_url( __FILE__ ) );
define( 'H4B_IMG_OPTIM_SLUG', 'h4b-image-optim' );
require_once H4B_IMG_OPTIM_DIR . 'includes/class-plugin.php';
H4B\ImageOptim\Plugin::instance()->boot();