Skip to content

Product Images — Update

Equivalent to PUT /api/admin/catalog/products/{productId}/images/{id}.

Edits what is stored alongside an uploaded image: its alt text and its position. The file itself is fixed once uploaded — to replace the picture, upload a new one (REST only) and delete this one.

Operation

OperationType
updateAdminCatalogProductImageMutation

Input

FieldTypeRequiredNotes
idID!yesThe image's IRI, e.g. /api/admin/catalog/products/12/images/47.
productIdIntnoParent product id. Taken from the image when omitted.
imageIdIntnoImage id. Taken from id when omitted.
altTextStringnoDescription of the image, stored for every locale the request covers. Send an empty string to clear it.
positionIntnoSort position within the product's gallery.

At least one of altText and position is required — a mutation carrying neither is rejected.

Alt text and locales

Alt text is translated: it is written for every locale the request covers, and read back for the locale the request is made in. The storefront returns it as altText on the product's images, and falls back to the product name where an image has none, so an image is never rendered without a description.

Images resolve in position order, so this is what decides which picture is the product's main image — the lowest position wins, and that is the one the listing and the product card show. To rearrange several at once, use reorder instead.

Response fields

FieldTypeNotes
_idIntImage id.
productIdIntParent product id.
pathStringStorage-relative file path.
positionIntSort position.
urlStringPublic URL.
altTextStringAlt text stored for the current locale, or null.
successBooleanWhether the edit was applied.
messageStringHuman-readable result message.

Released under the MIT License.