Skip to main content
Cookbook Content NextGEN Gallery

Make a Photo Gallery Page from Your Media Library with NextGEN Gallery and AI

A NextGEN gallery built from photos already in your media library, with alt text, placed on a new draft page.

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 photos are already in your media library.

The prompt
My WordPress site uses NextGEN Gallery. Make a gallery from my photos of [what the photos show, or words from their titles] and put it on a new draft page called [page title].

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. Search my media library with rest_api GET /wp/v2/media with search set to my words, media_type image, per_page 50, context edit and _fields id,title,alt_text,caption,source_url. It matches every word in titles, captions and descriptions, so if nothing fits, try each word on its own. Show me the matches as a numbered list with title, alt text (or: no alt text) and source_url as the link; if 50 come back, tell me there may be more and offer to narrow the words. Wait for me to pick the photos and their order.
3. Before making anything, check both titles: run nextgen-gallery/list-galleries with search set to the page title, and rest_api GET /wp/v2/pages with search set to it, status publish,draft,private,pending,future and _fields id,title,status,link. If a gallery or a page with that title exists, show it and ask whether to make a new one anyway. Then run nextgen-gallery/create-gallery with title set to the page title. Tell me its gallery ID.
4. Run nextgen-gallery/add-images with the gallery_id and up to 20 attachment_ids at a time, in my order. If any come back in remaining, send those next, not the whole list again. Never send a photo twice: each call imports a fresh copy, so it would show twice. If a call fails or gets no answer, do not send it again: read the gallery's newest images with rest_api GET /imagely/v1/images with gallery_id GALLERY_ID, orderby pid, order DESC, per_page set to how many photos you sent, and _fields inside query set to pid,filename,image_slug,alttext to see what was added, and send only what is missing. Tell me each one in skipped with its reason, and any in warnings. If nothing was added, stop and tell me why, and that the empty gallery GALLERY_ID is left over (it shows nowhere until a page places it).
5. Read the new images with rest_api GET /imagely/v1/images with gallery_id GALLERY_ID, orderby pid, order DESC, per_page set to how many photos you sent, and _fields inside query set to pid,filename,image_slug,alttext, and keep the ones whose pid is among the image_ids add-images returned, or that you found added after a failed call. The added and image_ids lists line up, one image per photo in the same order, so the first image_id came from the first id in added, and so on. 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. For each new image that needs alt text, propose one: the media library alt_text of the photo it came from (from the media library search) if it has one; otherwise write about 125 characters or fewer, from the photo itself if you can see it at its source_url, else from its title, caption and file name, marked as a guess. Show me the list (image, current alt text, proposed alt text) and wait for my yes or edits. For each approved image, save it with rest_api_write PUT /imagely/v1/images/PID with alttext only. Never change alt text that does not need it by these rules.
6. Create the page with rest_api_write POST /wp/v2/pages with the title, status draft, and content: a paragraph block with one short line about the photos if I gave you one, then a Shortcode block (the block comment wp:shortcode) holding the imagely shortcode with id="GALLERY_ID" inside square brackets. Do not publish the page.
7. Check: run nextgen-gallery/get-gallery and confirm image_count matches. Read all 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,exclude,meta_data.md5 (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. Confirm they are in my order and none still needs alt text unless I said to leave it. Run rest_api GET /wp/v2/pages/PAGE_ID with context edit and _fields id,status,content.raw and confirm the content holds the shortcode with the right id. Give me the link to edit the page and tell me the gallery appears on the page when I publish it (a NextGEN Gallery widget showing recent images may show the photos already), in my order as long as NextGEN's gallery sort setting is the custom order (the default).
Already connected?

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

Run the “Make a Photo Gallery Page from Your Media Library with NextGEN Gallery and AI” recipe from the WPVibe cookbook on my connected site.

The photos from the event, the finished project or the new menu are already in your media library. Turning them into a NextGEN gallery still means making the gallery, importing each photo, fixing its alt text and placing it on a page, so the photos sit unused.

Tell the AI what the photos show. It searches your media library, shows you the matches, and builds a NextGEN gallery from the ones you pick, in your order. Photos that come in with no real alt text get proper alt text, saved only after your yes. Then it puts the gallery on a new draft page, which stays a draft until you publish it.

NextGEN copies each photo into the gallery and gives it the media library caption as its alt text, or, without one, a title saved in the photo file or else its file name, so the AI checks every photo after the import. A gallery has no draft of its own: it shows where a page places it, and its photos can show at once in a NextGEN widget that lists recent images. The recipe makes a block editor page; on a page builder, place the gallery with the builder’s shortcode element. To add photos to a gallery you already have, use this recipe.

Outcome

A NextGEN gallery of the photos you picked, in your order and with alt text, on a new draft page that shows it once you publish the page.