Integration Module 2.0 for Medusa is outRead the announcement
I

Image alt

Alt text for product images in Medusa v2, per language, edited in the Admin (product page widget + an "Image alt" page listing the photos still missing one, with coverage per language); stored by image URL so it survives media re-uploads; automatic fallba

npm install medusa-image-alt
Category
Built by
Version
0.1.0
Last updated
6 days ago
Monthly downloads
Loading downloads

Haus Kayu

medusa-image-alt

Alt text for your product photos, per language, written in the Medusa Admin. A widget on the product page (one field per photo and language, character meter, the empty ones marked), an "Image alt" page that lists every photo still missing a text with the coverage per language and bulk editing, an automatic fallback text, a Store API per locale, a revalidate hook, and a storefront integration for Kiln.
Teks alt foto produk per bahasa dari Admin Medusa: widget di halaman produk, halaman daftar foto yang masih kosong dengan cakupan per bahasa, teks otomatis, Store API per locale.

npm CI Medusa license: MIT

Why

Medusa's has no field (checked through 2.22.7), and its Admin saves a product's media as : every save re-creates the image rows with new ids and without their . Anything kept in or keyed by image id is lost the next time somebody drags a photo around. This plugin keeps the texts in its own table, keyed by the image URL, which only changes when the photo itself is replaced.

Compatibility

PluginMedusaNodeTested in CI on
0.1.x2.19.0 or newer 2.x ()20.19+ or 22.12+Medusa 2.19.0 and 2.22.2

No other service needed.

Quick start

npx medusa db:migrate

Open a product in the Admin: the Image alt text block under the product details has one field per photo and language. Image alt in the sidebar lists the photos that still have none. The storefront reads .

The widget on the product page: thumbnail, one text field per language with a character meter, the empty ones marked

The Image alt page: coverage per language, filter, the photos missing a text with their fields, one save for all

What you write

Notes
One text per photo and languageDescribe what is in the picture ("Teak bowl, 15 cm, on a linen cloth"), not "image of". The Admin counts characters against a suggested maximum (, default 125, what screen readers read in one go); the hard limit is 500.
Empty fieldVisitors get the automatic text (below) until you write one. The field's placeholder shows it.
Variant photosA photo attached to variants (Medusa 2.11+) gets their titles in the automatic text ("Teak bowl 15 cm – photo 2").

Automatic text (fallback)

An image without a text in the asked language answers (English) or (Indonesian); other languages use the English template unless you add one. follows Medusa's Translation Module when the project translates its catalog. Empty placeholders leave no double spaces or dangling dashes. Switch it off with : an image without text then answers the default language's text, else , and your storefront decides (Kiln falls back to the product title).

Options

OptionDefaultNotes
BCP 47 codes; the first is the default. Visitors asking for get .
Suggested length shown in the Admin (not enforced; 500 is).
Automatic text for empty fields.
Per locale or language; placeholders .
–: changes are batched and sent as .
A small "Image alt by Haus Kayu" line under the Admin page.

Store API

Keyed by the image URL because that is what a storefront has at hand everywhere: the gallery, a product card's thumbnail, a cart line's thumbnail. Published products only; may also come from the header. The answer carries ; with the option the storefront learns about changes at once. An unknown id simply answers an empty map (a storefront probes the route this way to detect the plugin).

Typed SDK

wraps the Admin routes (, , , , , ). Only is used, so any object with that shape works.

Admin API

All under (session or bearer):

Route
Non-secret options the Admin adapts to.
The product's photos: per locale, the each would get, locales.
: only the locales sent change; or clears one. Only the product's own photos.
Photos across the catalog (newest products first) with their product, filtered by what is missing; plus of the whole catalog.
: bulk write (up to 500).
.

Rule violations answer / with ; codes: , , , , .

How it is stored

One table, : (unique), (), and as the last ones seen (the subscriber refreshes them after a media save; they only group the Admin list). Nothing is deleted when a photo disappears from a product: if the same URL comes back, its text is there. Texts are trimmed, inner whitespace collapsed, control characters removed.

The Admin list reads the catalog in batches of 100 products (capped at 5000) and filters in memory, which is instant for catalogs up to a few thousand photos.

Storefront

Kiln 0.6+ detects the plugin () and uses the texts in the product gallery, on product cards, in the cart and checkout summary, and for the share image and JSON-LD captions; without the plugin it keeps its own fallback (product title + position). Any other storefront: fetch for the products of a page (cache it with the product) and read .

Development

See CONTRIBUTING.md. runs the whole suite against a local Postgres container.

License

MIT © Haus Kayu