Skip to content

[6.x] Localizable Asset Meta Data#13928

Open
jackmcdade wants to merge 23 commits into6.xfrom
localizable-asset-meta-data
Open

[6.x] Localizable Asset Meta Data#13928
jackmcdade wants to merge 23 commits into6.xfrom
localizable-asset-meta-data

Conversation

@jackmcdade
Copy link
Member

@jackmcdade jackmcdade commented Feb 13, 2026

References statamic/ideas#223

CleanShot 2026-02-13 at 12 19 15@2x CleanShot 2026-02-13 at 12 20 15@2x

Note

High Risk
Touches core asset persistence and meta caching semantics, adds locale-dependent merging/origin logic, and changes CP/API/GraphQL request/response behavior; regressions could impact asset editing/saving across sites.

Overview
Enables localizable asset field metadata (eg. alt text) by introducing locale-aware asset instances (Asset::locale(), Asset::in()) and persisting meta in a per-site data[siteHandle] structure with origin/merge behavior, cycle-safe resolution, and locale-specific meta caching.

Updates the CP asset editor and assets fieldtype to pass/select an active site, display a localization selector, track per-locale modified fields, and include site/_localized in save requests; adds error/empty-state handling and prevents keyboard navigation shortcuts while typing.

Extends CP/API/GraphQL endpoints and resources to accept a site parameter and expose locale, adds an asset-container localizable toggle in the CP (hidden when multisite is off), and introduces statamic:assets:migrate-localizable to normalize existing YAML/Eloquent metadata; adds focused tests covering preservation of other locales, non-materialization of inherited values, focal-point non-localization, and cyclic origin maps.

Written by Cursor Bugbot for commit 3f03e19. This will update automatically on new commits. Configure here.

@daun
Copy link
Contributor

daun commented Feb 13, 2026

Yay 🎉 May I suggest a tab interface for switching between localizations? We've tried a few custom iterations and all of our clients preferred this type of interface for switching between localizations:

Screenshot 2026-02-13 at 20 46 01

@jasonvarga
Copy link
Member

That'll work when you have a couple of sites, but once you have more than a few it'll fall apart quickly. We will note that though!

@daun
Copy link
Contributor

daun commented Feb 13, 2026

Yeah. Good point. Maybe that's a case for if (sites.length > 3) or so. In my experience, it's either 2-3 sites or 11 sites.

@jackmcdade
Copy link
Member Author

Yeah. Good point. Maybe that's a case for if (sites.length > 3) or so. In my experience, it's either 2-3 sites or 11 sites.

Yeah maybe — though for now I'd rather keep things simple and just get it working first. A select box works everywhere. :)

`localizationData()` calls `origin()->values()` when `hasOrigin()` is true. With a cyclic sites origin map, this enters recursive origin resolution via `values()` and can loop indefinitely while serializing CP asset responses.
When saving a localized asset (e.g. rename/move), hydrate() was filling $data with origin-merged values and meta() was writing that merged set into data.{locale}, turning inherited fields into explicit overrides.

Add localizedDataForPersistence() to only persist explicit localized
data when no mutation occurred. If $data is unchanged from the
hydrated view and removedData is empty, keep the existing explicit
localized bucket as-is.
@jackmcdade jackmcdade marked this pull request as ready for review February 14, 2026 03:59
Show error state and Retry when the asset request fails instead of
rendering with null asset and crashing on asset.path.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


this.activeSite = site;
this.load(site);
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed locale load keeps stale editor state

Medium Severity

localizationSelected sets activeSite before load(site), but on load failure the catch block only sets loadError and leaves existing asset data intact. The UI can show prior-site data while activeSite points to a different locale, causing edits to be saved under the wrong site context.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments