Skip to main content
Cookbook Content FooGallery

Add or Remove Photos in a FooGallery Gallery with AI

New photos added to a FooGallery gallery, or old ones taken out, after you see exactly what changes.

Difficulty Beginner
Time ~5 min

Prerequisites

A site connected to WPVibe running a recent FooGallery (tested on 3.3.37, free) on WordPress 6.9 or newer, with an administrator account. The new photos are already in your media library.

The prompt
My WordPress site uses FooGallery. In my [gallery name] gallery, [add my photos of what they show, or remove the photo of what it shows].

1. Run discover_abilities with category foogallery-management. If the FooGallery abilities are not there, stop and tell me to install the free FooGallery plugin or update it to the latest version (it needs WordPress 6.9 or newer). If a FooGallery ability answers that it does not have the necessary permission, tell me to open any page of my WordPress admin once while signed in as an administrator (FooGallery sets up its gallery permissions there, and misses them when it was activated without an admin page loading, for example with WP-CLI), then try again. If it still answers that for one gallery, that gallery ID does not exist: check it with foogallery/list-galleries.
2. Run foogallery/list-galleries with search set to words from the gallery name and status any. If several match, show them with their photo counts and ask which one. If none match, run it again without search and show me the list.
3. Run foogallery/get-gallery with the gallery_id and include_attachment_detail true. If its datasource is not media_library, tell me its photos come from somewhere else and stop. Show me its photos in order as a numbered list with title and link. If its sort is not empty, tell me visitors see the photos in that order (by date created or modified, title, or at random), not in the list order. If attachment_ids holds IDs that are not in attachments, tell me those photos were deleted from the media library.
4. Find where the gallery is shown: run rest_api GET /wp/v2/pages and GET /wp/v2/posts, each with search foogallery, status publish,draft,private,pending,future, context edit, per_page 100 and _fields id,title,status,link,content (if 100 come back, ask for page 2). A post shows the gallery when its content has a FooGallery block (fooplugins/foogallery) with id GALLERY_ID, or a foogallery shortcode with id GALLERY_ID, or with gallery set to its ID or slug (get its slug with rest_api GET /wp/v2/foogallery/GALLERY_ID with context edit and _fields slug). This does not see galleries on other content types, such as products or courses, or placed with a page builder widget, a theme template or a sidebar widget. Tell me where it is shown. If any of those posts is published, or the gallery is published (it may be shown somewhere this search can't see), tell me visitors see the change as soon as it is saved: a change to a gallery can't be saved as a draft first.
5. To add: run foogallery/media-search with search set to my words and limit 50. It matches my words as one phrase in titles, captions, descriptions, alt text, file addresses and media categories, so if nothing fits, try each word on its own. It searches every file in the media library and does not say which are images: keep only the ones whose url ends in an image file extension (jpg, jpeg, png, gif, webp, avif) and whose width is above 0. Leave out photos already in the gallery, show me the rest as a numbered list with title, alt text (or: no alt text) and link, and wait for my pick. To remove: pick from the gallery's own list in step 3. If the change would leave the gallery with no photos, stop and tell me; don't send it. Show me what will be added and removed, and wait for my yes.
6. Run foogallery/update-gallery-attachments once with the gallery_id, append_attachment_ids set to the photos to add (they go at the end) and remove_attachment_ids set to the photos to remove; leave out whichever is empty. Never send replace_attachment_ids: it replaces the whole list, and an empty list empties the gallery. Removing takes a photo out of this gallery only; it stays in the media library.
7. Run foogallery/get-gallery again. Tell me the photo count before and after and the titles added and removed, and list added photos with no alt text. Give me the sentence to undo it: In the FooGallery gallery GALLERY_ID, remove ADDED_IDS and add back REMOVED_IDS with foogallery/update-gallery-attachments (use the real IDs, and leave out a part that is empty). Photos added back go at the end of the list; to change the order, drag them in the gallery's edit screen in WordPress admin.
Already connected?

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

Run the “Add or Remove Photos in a FooGallery Gallery with AI” recipe from the WPVibe cookbook on my connected site.

A gallery is never finished: new projects, this season’s menu, last weekend’s event. Adding photos means opening the gallery, searching the media picker and saving, and removing an old one means finding it among dozens of thumbnails, so galleries go stale.

Tell the AI which gallery and which photos. It shows you what the gallery holds now and where it is shown, searches your media library for the new photos, leaves out the ones already in it, and adds or removes only what you pick in one change. It reads the gallery back and gives you one sentence to undo it.

A change to a gallery can’t be saved as a draft first: on a published page, visitors see it as soon as it is saved, so the AI asks first. Removing a photo takes it out of this gallery only; it stays in your media library. New photos go at the end of the list, which is the order visitors see unless the gallery is set to sort by date created or modified, title, or at random; to change the order, drag them in the gallery’s edit screen. To start a new gallery, use this recipe.

Outcome

The gallery holds the photos you added and not the ones you removed, with every other photo as it was, and you have the sentence that undoes it.