Skip to content

[6.x] Localizable Asset Meta Data#13928

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

[6.x] Localizable Asset Meta Data#13928
jackmcdade wants to merge 21 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 metadata read/write and caching behavior and introduces a migration path; bugs could cause metadata loss/corruption or incorrect locale resolution across sites.

Overview
Enables per-site/localized asset field metadata (eg alt/title) for multi-site installs, gated by a new asset-container localizable toggle.

Updates asset persistence to store meta data keyed by locale with an optional sites origin map, adds locale-aware caching/normalization, prevents inherited values from being materialized on save, and keeps focal points effectively non-localized. CP asset show/update, fieldtype asset hydration, API/GraphQL queries, and the asset editor UI now accept a site/locale context (including a localization switcher with unsaved-changes confirmation).

Adds statamic:assets:migrate-localizable to migrate existing meta files (and Eloquent-driver meta JSON rows when possible) into the localized structure, plus broad test coverage for localized saving, origin/cycle safety, and migration behavior.

Written by Cursor Bugbot for commit c0c83dc. 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
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.

}).catch(() => {
if (loadId === this.loadId) {
this.loading = false;
}
Copy link

Choose a reason for hiding this comment

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

Failed load renders editor with null asset

Medium Severity

In load()’s catch, loading is set to false without setting an error state or guarding asset. The template then renders sections that dereference asset (like asset.path) while it is still null, causing a runtime crash after failed requests.

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