Extroverting R2 Media
Cloudflare R2 + Workers AI enrichment for the WordPress Media Library: generates image descriptions, titles, and tags, stores them in post meta, and writes them back into source files via exiftool (PNG tEXt, EXIF, XMP incl. AltTextAccessibility).
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/smcnally/extroverting-r2-media/archive/refs/heads/main.zipCloudflare R2 + Workers AI enrichment for the WordPress Media Library.
What it does
-
On attachment upload (
add_attachment), schedules async AI enrichment via WP-Cron. -
Sends the image (base64) to the Cloudflare Worker (
/enrichroute), which uses Workers AI (Llama 3 for description/title/tags, DETR-ResNet-50 for object detection). -
Saves results to post meta (
_ext_ai_*) and updates the attachment's content, title, tags, and alt text in WordPress. -
Writes metadata back into the source file with exiftool (
Ext_Exif_Writer):Format Fields written PNG Description,Title,Collection(stored as tEXt chunks)JPEG EXIF:ImageDescriptionXMP (PNG/JPEG/TIFF/WebP) Description,ImageTitle,Categories(joined tags + categories),ModifyDate,AltTextAccessibility-en-US(mirrors Description)
Configuration
Settings > Media in wp-admin (or options table):
ext_ai_worker_url— Cloudflare Worker base URLext_ai_worker_token— Bearer token for the Workerext_exiftool_binary— exiftool binary name (PATH-resolved) or absolute path (override also viaext_r2_media_exiftool_binaryfilter)
Local dev notes
-
Local site: http://127.0.0.1:8099/ — Docker container
extroverting-dev(imagelocal/php-mysql:8.1), serving../extroverting-theme-repoat/app. -
The plugin runs inside that container, so exiftool must be installed there:
docker exec extroverting-dev apt-get update && \ docker exec extroverting-dev apt-get install -y libimage-exiftool-perlThis is ephemeral — repeat it if the container is recreated (or bake it into the image).
-
The deployed copy lives at
../extroverting-theme-repo/wordpress/wp-content/plugins/extroverting-r2-media/(copied, not symlinked, matching theextroverting-coreconvention). Re-copy after making changes here. -
The Worker code lives in
./cloudflare-worker/(wrangler deploy required for end-to-end enrichment; without it, enrichment status isfailedby design). Deploy steps and notes are incloudflare-worker/DEPLOY.md.
Files
extroverting-r2-media.php— plugin bootstrap, settings, cron wiringincludes/class-ext-ai-enrichment.php— Worker request/response, post meta, batch cronincludes/class-ext-exif-writer.php— exiftool metadata writer (shell-safe, idempotent)