Skip to main content

Fix Alt Text in a NextGEN Gallery with AI

Alt text written for each photo in a NextGEN gallery that has none or only its file name, saved after you approve it.

Difficulty Beginner
Time ~10 min

Prerequisites

A site connected to WPVibe running NextGEN Gallery 4.6.0 or newer (free) on WordPress 6.9 or newer, with an administrator account. Allow AI to edit galleries is turned on in your WordPress admin under Imagely, Settings, AI & MCP.

The prompt
My WordPress site uses NextGEN Gallery. Write alt text for the photos in my [gallery name] gallery that have none or only a file name.

1. Run discover_abilities with category nextgen-gallery. If the NextGEN Gallery abilities are not there, stop and tell me to install the free NextGEN Gallery plugin or update it to 4.6.0 or newer (it needs WordPress 6.9 or newer). Then run nextgen-gallery/describe-gallery-schema. If writes_enabled is false, stop and tell me to turn on Allow AI to edit galleries in my WordPress admin under Imagely, Settings, AI & MCP, then ask again. Never change that setting yourself. Where a step says _fields inside query, put _fields in the query parameters, not in WPVibe's fields option, which on NextGEN's routes keeps whole nested blocks such as meta_data.
2. Run nextgen-gallery/list-galleries with search set to one distinctive word from the gallery name (it matches the text as one phrase), per_page 50 and max_length 100000 (if a response says it was cut, lower per_page and page through). If several match, show them with their image counts and ask which one. If none match, try another word, then run it without search and show me the newest 50; if total_pages is more than 1, ask whether to read the next page.
3. Read its images with rest_api GET /imagely/v1/images with gallery_id GALLERY_ID, per_page 100, page 1, max_length 100000 and _fields inside query set to pid,filename,image_slug,alttext,image_url,description (if a full page comes back, read the next page, and so on). If a response says it was cut (truncated), restart at page 1 with a lower per_page. An image needs alt text when its alttext is empty, is its file name (the same as its image_slug, or its filename with or without the extension), or is text a camera writes by itself, such as OLYMPUS DIGITAL CAMERA or SONY DSC. NextGEN gives an imported photo the media library caption as its alt text; with no caption, a title saved inside the photo file, if any; otherwise its file name. It never copies the media library alt text. Stop reading pages once you have 20 images that need alt text: that is this run. If you stopped early, tell me there may be more for the next run; otherwise tell me how many need alt text in all. Note the per_page you used and the page number each one came from.
4. For each, write alt text of about 125 characters or fewer that says what the photo shows: from the photo itself if you can see it at its image_url, otherwise from its file name and description, marked as a guess. Skip file names that say nothing, such as IMG_4032, unless you can see the photo; list those as needing my words. At the end of the run, tell me the last pid you checked; on a later run, if I say continue after that pid, read in the same order with the same per_page and start with the image that comes after it in that order, so the run moves on to new photos. Tell me this text is also the photo's title in the lightbox. Show me the list (image, current alt text, proposed alt text) and wait for my yes or edits.
5. Right before saving, read the same pages again with the same per_page and _fields inside query set to pid,filename,image_slug,alttext. Skip any approved image that is no longer there or no longer needs alt text (someone changed it). Save each of the others with rest_api_write PUT /imagely/v1/images/PID with alttext only.
6. Read those pages once more the same way and confirm each saved image reads back as saved. Tell me how many were saved, skipped, or still need alt text.
Already connected?

Skip pasting the full prompt. Drop this into your AI on a site that already has WPVibe:

Run the “Fix Alt Text in a NextGEN Gallery with AI” recipe from the WPVibe cookbook on my connected site.

NextGEN gives each photo it imports the media library caption as its alt text, or, without one, a title saved in the photo file or else its file name. So galleries fill up with alt text like IMG_4032 or harbor-final-2, which screen readers read out and search engines learn nothing from, and the same text shows as the photo’s title in the lightbox.

The AI reads the gallery, lists every photo whose alt text is empty or just its file name, and writes a short description for each from the photo itself when it can see it, or from its file name and description, marked as a guess; when neither says anything, it asks you for the words. You check the list, and only the ones you approve are saved, one photo at a time.

Each NextGEN gallery keeps its own copy of a photo, so this changes the gallery only: the media library and other galleries keep theirs. Changes show at once on any page that shows the gallery. The AI never overwrites alt text someone wrote, and works 20 photos at a time on a large gallery. For images outside NextGEN, use this recipe.

Outcome

Up to 20 photos a run whose alt text was empty, a file name or camera text have the alt text you approved, and every other photo is unchanged.