Documentation · Operations and Maintenance
Image Queue Maintenance
This document explains how the plugin's asynchronous image queue works, how to monitor its progress, and how to maintain, manually process, or clear the queue in production.
When to use this document
Read this document if you are a site administrator and you need to understand why vehicle images are not yet appearing after an import, why the image queue is growing, or how to manage image downloads on sites with large catalogues or constrained server resources.
Overview
When the Image queue mode is enabled (the default for scheduled and REST-triggered imports), the plugin does not download all vehicle images during the main import run. Instead:
- Only the first image of each vehicle is downloaded immediately during the import.
- The remaining image URLs are stored in a persistent queue in the WordPress options table (
as24ci_image_queue). - After each import run, a separate image queue worker is scheduled as a WP-Cron single event to process the queued images in batches.
- The worker runs repeatedly, processing 30 images per batch, until the queue is empty or the time budget is exhausted.
This approach keeps each import run short and predictable, even for catalogues with many images per vehicle.
For manual imports triggered from the Importer tab (not through cron or REST), queue mode is disabled by default and all images are downloaded immediately during the import.
How the image queue worker operates
The image queue worker:
- Acquires its own transient lock (
as24ci_image_queue_running, TTL 10 minutes) to prevent overlapping workers. - Reads the current queue from the
as24ci_image_queueoption. - Processes items in batches of 30 images, checking after each batch whether the time budget (the lock TTL minus 60 seconds, approximately 540 seconds) has been reached.
- Writes the remaining queue back to the database after each batch.
- Records run statistics (
processed,failed,remaining,timestamp) in theas24ci_image_queue_last_runoption. - If items remain after the time budget is exhausted, schedules another single WP-Cron event immediately so processing continues in the next available request.
- Releases the lock when done.
After all queued items for a vehicle post have been processed, the worker rebuilds the _as24ci_image_ids post meta from the actual attachment IDs in the database and finalises the image hash, so the next import run can correctly detect future changes.
Image deduplication
The image importer deduplicates images by source URL. Before downloading an image, it checks whether an attachment with the same _as24ci_source_url post meta already exists. If a match is found, the existing attachment is reused rather than downloaded again. This applies to both immediate and queue-mode imports.
This means re-running an import or re-processing the queue will not create duplicate attachments for images that were already successfully imported.
WebP conversion
If the Convert to WebP option is enabled, each downloaded image is converted to WebP format before being added to the media library. The plugin tries GD first, then Imagick as a fallback. If neither is available or conversion fails, the original image format is used. Conversion results are logged at warning level when they fail.
WebP quality is configurable (1–100, default 80). The quality value can also be overridden at the code level via the as24ci_webp_quality filter.
Monitoring the image queue
System & Help tab
- Open ADP Car Market Hub → System & Help.
- In the Background Tasks table, find the Image Processor row (hook:
as24ci_image_queue_process). - The Next Run column shows when the next worker invocation is scheduled.
- The Status column shows: - Scheduled (green) — a worker event is queued - Running (amber) — the worker is currently active - Lock stuck (red) — a stale lock was detected; it will be auto-cleared on the next run attempt - Not scheduled (amber) — no worker is currently queued (expected when the queue is empty)
- The System & Help tab shows a warning badge when the queue size exceeds 1,000 items, indicating that image processing is falling behind.
Image queue last-run stats
The plugin stores the results of the most recent worker run in the as24ci_image_queue_last_run option. These stats include:
processed— images successfully downloaded in the last runfailed— images that could not be downloadedremaining— items still waiting in the queuetimestamp— Unix timestamp of the last run
These values are displayed in the System & Help tab and can be used to assess queue throughput.
Import & Limits tab
The Automation tab provides manual control actions for the image queue:
- Run image queue now — triggers the worker immediately via an AJAX request. Useful when you want to force image processing without waiting for the next scheduled event.
- Clear image queue — discards all pending items in the queue. Use this when you want to stop image processing, for example if a large batch of incorrect images was queued. This does not delete images that have already been downloaded.
Step-by-step: processing a stuck image queue
- Open ADP Car Market Hub → System & Help.
- Check the Background Tasks table for the Image Processor row. If the status is Not scheduled but the queue is not empty (the warning badge is visible or the last-run stats show a non-zero remaining count), the worker cron event was not re-scheduled.
- Click Run Image Queue Now in the System & Help tab action bar to start a worker immediately.
- Wait for the run to complete (typically a few seconds to a few minutes depending on queue size).
- Refresh the System & Help tab to verify that the queue is decreasing.
- If the worker runs but the queue is not decreasing (for example, if all images are failing), check the log for
[ERROR]and[WARNING]entries related toImage queue workerorImage download failed.
Step-by-step: clearing the image queue
Use this procedure when you want to abandon all pending image downloads (for example, after removing a seller ID or after a bulk delete of vehicles).
- Open ADP Car Market Hub → System & Help or Import & Limits.
- Click Clear Image Queue.
- Confirm the action when prompted.
- The queue option is cleared and no further background image downloads will occur for the discarded items.
- Vehicles that had their remaining images cleared will only have the first image (downloaded during the import run) until the next full import.
Queue size limits
The plugin imposes a hard limit of 20,000 items in the image queue. If the queue grows beyond this limit, a warning is logged and a deduplication pass is run to collapse duplicate entries. Verify this behavior in the current plugin version before publishing.
Configuration reference
| Setting | Default | Purpose |
|---|---|---|
Image queue mode (as24ci_cron_image_queue) | On (1) | When enabled, only the first image is imported immediately during cron/REST runs; remaining URLs are queued |
Max images per vehicle (as24ci_max_images) | 0 (unlimited) | Caps the total number of images imported per vehicle regardless of queue mode |
Convert to WebP (as24ci_convert_to_webp) | Off (0) | Convert downloaded images to WebP before adding to the media library |
WebP quality (as24ci_webp_quality) | 80 | Conversion quality, 1–100 |
| Image queue batch size | 30 | Fixed in code (Scheduler::IMAGEQUEUEBATCH_SIZE); not configurable in the UI |
| Image queue worker lock TTL | 600 seconds (10 min) | How long the worker lock is held before being considered stale |
| Image queue warning threshold | 1,000 items | Queue size above which the System & Help tab shows a warning badge |
Operational notes
- Image queue mode is only applied during imports triggered by WP-Cron or the REST cron endpoint. Manual imports from the Importer tab always download all images immediately (unless the max images limit applies).
- The image queue persists across import runs. If the worker has not finished processing a previous batch when a new import runs, the new image URLs are appended to the existing queue.
- If a vehicle post is deleted after its image URLs were queued but before the worker processes them, the worker silently skips items whose post no longer exists.
- The image queue stores per-item metadata including the vehicle post ID, the listing ID, the image URL, and an image hash. This allows the worker to finalize image hashes correctly after all images for a vehicle have been processed.
- On sites with large catalogues (hundreds of vehicles with many images each), the image queue may grow to several thousand items after the first import. This is expected behavior. The queue will decrease steadily over subsequent worker runs as long as WP-Cron (or the image-queue worker cron hook) is running.
- If disk space in the uploads directory is low, image downloads will fail. The System & Help tab shows disk space availability. Free space before running a large image import.
Troubleshooting
| Symptom | Likely cause | Check |
|---|---|---|
| Vehicle images not appearing after import | Queue mode is active and worker has not yet run | Check System & Help tab for image queue status; click Run Image Queue Now |
| Image queue size not decreasing | Worker cron not running, or all image downloads failing | Check Background Tasks status; review log for image download errors |
Image download failed errors in log | Source images unavailable or download timeout | Verify the listing is still active in AutoScout24; check server outbound connectivity |
| WebP conversion errors in log | GD or Imagick not available or misconfigured | Check PHP extension status in System & Help tab; disable WebP conversion if not needed |
| Lock stuck badge for Image Processor | Worker did not release its lock cleanly | Lock auto-clears after 10 minutes; click Run Image Queue Now to reset |
| Queue growing unbounded | Many imports with large image sets; worker not keeping up | Consider reducing max images per vehicle; confirm WP-Cron is reliable |