Skip to content

Add multi-upload and ordered gallery support - #124

Open
RandyCupic wants to merge 63 commits into
4.0from
multiupload
Open

RandyCupic wants to merge 63 commits into
4.0from
multiupload

Conversation

@RandyCupic

@RandyCupic RandyCupic commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Replaces #122, rebased onto 4.0 (the branch was renamed from 3.0-multiupload to multiupload, which closed #122).

Lets a remote media form field hold several resources. Editors can select or upload several resources at once, reorder them, and edit alt text, caption, tags and crops per item. The field data is always an ordered collection of RemoteResourceLocation objects; upload_limit only limits how many items the field accepts.

  • One form type, RemoteMediaType, with a new upload_limit option (null for unlimited, the default, or an integer >= 1). Its data is always an ArrayCollection<int, RemoteResourceLocation>, also with 'upload_limit' => 1 (0 or 1 items), so changing the limit never changes the entity mapping or the stored data.
  • The whole selection is submitted as one JSON field, collectionPayload:
    • the form theme renders it with the current value, and a missing payload leaves the field as it is; only an explicit [] clears it;
    • entry fields are type-checked, so a malformed payload makes the form invalid instead of a 500;
    • a repeated locationId is kept once, and location ids that don't belong to the edited value are ignored;
    • over the limit the form is invalid, with a translatable message (validators domain, en/hr/no) shown at the field (error_bubbling is false);
    • after an invalid submit the widget shows what was submitted (order, new items, crops), not the stored value. It uses only resources stored locally, so showing it never calls Cloudinary.
  • Each item shows the alt text and caption stored in Cloudinary and the location overrides (altTextOverride, captionOverride) from JGLWEB-1835 add local alt text and caption overrides #128 next to each other, the same as the CKEditor plugin. Both are carried through the payload. A change of the Cloudinary values or the tags updates the resource in Cloudinary through RemoteResourceService::handleRemoteUpdate(), as before.
  • A field without resources is empty for Symfony (isEmpty()), also with the [] payload, so an optional embedded form whose fields are all empty doesn't get an object created from its empty_data.
  • Order is stored in a new nullable position column on ngrm_remote_resource_location (migration Version040000). The form sets it on submit and sorts by it; entities add #[ORM\OrderBy(['position' => 'ASC'])].
  • Upload panel:
    • drag and drop, per-file name, folder, visibility and overwrite, retry for failed uploads;
    • starts in parent_folder, shows a fixed folder read-only on every row;
    • with limit 1 an upload replaces the current item and keeps its watermark;
    • row uploads respect the limit, the same file can't be queued twice, empty file names are rejected;
    • per-file error handling, an idle timeout and the server's error message (the upload endpoint answers its errors with a 400 and the translated message in detail, so it shows in prod too);
    • the form submit is blocked, with a message above the panel, while files wait or upload. The click on a submit button is blocked too, so hosts like the Sylius loadable form don't freeze, and an ngrm-submit-blocked event lets other hosts undo their own submit state. Buttons with formnovalidate or data-ngrm-skip-submit-block (eg. Cancel, Delete draft) are never blocked, and in a hidden tab the message is also shown at the top of the page;
    • a row upload and a retry disable the panel and show progress like Upload all, and running uploads are cancelled when the panel is destroyed;
    • Enter in the file name and new folder inputs doesn't submit the form, and every folder picker has an accessible name.
  • Picker: multi-select, drag to reorder, items already in the field are marked as added and can't be added twice. Folder placeholders never create folders in Cloudinary, and "Create folder" works from the upload folder picker.
  • CKEditor: the preview sends one debounced change event again (no focus loss while typing), the embed CSS class and variation inputs are back, and /configuration returns all labels of the new UI. A widget's old Vue instance is destroyed when CKEditor renders it again.
  • The form templates and /configuration build their translations from one list (VueTranslations, ngrm_vue_translations()), checked by a test against the keys the Vue app reads. Norwegian translates the whole UI now, Croatian has the new keys, the folder picker's own texts are translated, ngremotemedia.nb.yaml is removed (Symfony falls back from nb to no), dead keys are removed.
  • Docs: FORM.md has a complete entity example (ManyToMany with a unique inverse join column, OrderBy on position, addX/removeX so orphan removal works) and describes the payload. CHANGELOG and UPGRADE.md have the 4.0 entries, including the OneToOne to to-many migration as a Doctrine migration class.
  • Tests: persistence test with Doctrine (POST, flush, reload: order, removal, additions), widget rendering test, entry validation, missing payload, view after an invalid submit, and the translation list.
  • Dist assets in bundle/Resources/public rebuilt (Node 12).

Behaviour changes:

  • RemoteMediaType data is always a collection. Single fields need a to-many relation and 'upload_limit' => 1; a field bound to a single RemoteResourceLocation fails with a TransformationFailedException. UPGRADE.md has the migration.
  • The only form child is collectionPayload. The named children (locationId, remoteId, altText, ...) and the hidden uploadLimit field are gone, so custom form themes that render them must be updated.
  • If a resource no longer exists in Cloudinary when its metadata is saved, from the form or from CKEditor (location/create, location/update), the local resource and its locations are kept and a warning with the remote id is logged. A submitted resource that exists neither locally nor in Cloudinary is left out as before, now with a warning too. Before, it was deleted locally, which also removed it from every other field using it. The Cloudinary delete notification and netgen:remote_media:refresh --delete still delete.
  • interactions.html.twig no longer takes location_id. Templates pass locations, and collectionPayload in input_fields.
  • An empty field is now isEmpty(), so optional CollectionType entries with delete_empty whose fields are all empty are removed.
  • handleRemoteUpdate() compares and stores tags sorted, so a different tag order no longer triggers a Cloudinary update on every save, and it stores an empty alt text or caption as null.
  • The ngrm-change event also carries config, and selectedImage.uploadedResources lists all items of the field.
  • The upload endpoint returns a 400 JSON response (detail) for a missing file, an unsupported visibility and a failed upload, instead of throwing an InvalidArgumentException (500).
  • RemoteMediaType errors are attached to the field, not to the parent form (error_bubbling is false).
  • The frontend lock file was re-resolved: Vue 2.6 to 2.7, vue-select 3.2 to 3.20, @babel/core 7.6 to 7.28, and regenerator-runtime became a direct dependency. vuedraggable is new. Builds use Node 12.

Notes:

Comment thread docs/CHANGELOG.md Resolved
@RandyCupic

Copy link
Copy Markdown
Member Author

@mivancic When you select multiple images in gallery, and then you go to select more, it doesn't show these that are already added as selected or grayed out. In fact, you can select them again. It won't add them again but it messes up with limitation. For example, I've put limit to 5 and I've selected 3 images. Then I went to select more, and again I've selected 2 of the same images so I was not able to select more (as I already had 5 images in total) but when you actually go to add them, there are only 3.

@mivancic

Copy link
Copy Markdown
Member

Thanks, reproduced. The picker only got the number of items already in the gallery, not which ones, so you could pick them again. They counted towards the limit, which blocked selecting more, and were then dropped as duplicates when added. Interactions now passes the IDs of the items already in the field through MediaModal to MediaGallery. Those items show as "Added", greyed out and not clickable, and they don't count towards the selection. The selection bar messages are now translated as well (en, hr, no, nb)

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I went through the code, translations and docs. I ran it in a Symfony 7.4 test app (with the #125 commits applied) and, at the exact head, in sklepex with CKEditor 5. I tested uploads in both folder modes, the picker, reorder, crops, protected files, the limits and tampered payloads.

Nice work. The per-file upload, folder for all files or per file, rename, the picker with "Added", and the server-side limit and ownership checks all work. A few things before merge.

Rebase first

I merged 3.0 into 4.0 (58299f95), and #133 is in too. 4.0 now has the Doctrine migrations (#129, #132), the alt/caption overrides (#128), the CKEditor 5 changes (#126) and generateLocationHtmlTag() on ProviderInterface. Please rebase multiupload onto it before the rework, so the overrides and the new position migration go in once.

  • A test merge conflicts in Interactions.vue, Preview.vue, interactions.html.twig, RemoteMediaTransformerTest.php, CHANGELOG.md, UPGRADE.md and the three dist files. For the dist files, take either side and rebuild (Node 12).
  • RemoteMediaTransformer and RemoteMediaType merge cleanly, but the collection path then drops altTextOverride/captionOverride, and every gallery save resets them to null. Per-item alt and caption should be the overrides, so carry them through the payload.

Must fix

  • The data is always a collection, limit 1 too, and the core keeps the order. See inline on isCollection() and RemoteMediaCollectionTransformer.
  • A missing collectionPayload empties the field, see inline.
  • CKEditor: focus is lost while typing, the embed CSS class and variation inputs are gone, and some labels are blank. See inline on Preview.vue and Configuration.php.
  • Upload panel: replacing at limit 1, parent_folder, a fixed folder, upload guards, retry, the row limit, folder create. See inline.
  • Entry type validation, missing resource handling, docs. See inline.

Smaller

  • "Clear completed" also removes error rows, including 409s with "use existing".
  • The same file queued twice isn't detected. "Use existing" for something already in the field shows success and adds nothing.
  • An empty filename can be uploaded.
  • An empty field now says "Manage media" (it was "Select media"). The visibility select shows even with a single option.
  • .limit-indicator is only styled inside MultiUploadInline. vuedraggable's :options is deprecated and warns in the console.
  • The per-row inputs and the icon buttons need labels or aria-labels.

Translations

  • no/nb: the new UI mixes Norwegian and English ("Overwrite (bruk på alle filer)", "Select" next to "Fjern markering"), because the new components reuse keys that were never translated. Please translate those and have someone who speaks Norwegian check them.
  • Dead keys: multi_upload.title, multi_upload.status.uploading, limit_info, and upload.button.use_existing_resource (mapped, but nothing reads it). Remove them or wire them up.
  • en: use sentence case like the rest of the file ('Upload all', 'Clear completed').

Tests

  • An owned location is kept in collection mode.
  • Reorder and removal of persisted items, with the real transformer.
  • Non-string entry fields.
  • An omitted field.
  • buildView after an invalid submit.
  • The Configuration keys.
  • One end-to-end test (POST → entity → flush → reload) that checks the order.

Please also update the PR description, it still mentions RemoteMediaCollectionType. I'll rebase platform (#125) after your rebase. allowed_types being checked only after the upload, allowed_tags without a server check and hide_filename doing nothing are older than this PR, so I'll take them as separate tickets.

Comment thread lib/Form/Type/RemoteMediaType.php Resolved
Comment thread lib/Form/Type/RemoteMediaType.php Resolved
Comment thread lib/Form/Type/RemoteMediaType.php Resolved
Comment thread lib/Form/Type/RemoteMediaType.php Resolved
Comment thread docs/UPGRADE.md Resolved
Comment thread frontend/package.json Resolved
mivancic and others added 24 commits November 14, 2026 10:20
Implement upload-limited multi-resource handling with multi-select and
reorderable gallery cards, split RemoteMediaType into single and
collection form types, convert the multi-gallery components to
props-down/events-up data flow, and improve the multi-upload UX, i18n
and wire format. Add a Norwegian Bokmål (nb) translation file.

Fix the CKEditor "Manage Media" modal so the gallery renders in
collection mode (default the embed to single-select and guard the
missing multi-select translation key that was blanking the gallery).
Includes rebuilt NGRM frontend assets (remotemedia.js +
remotemedia.css).
Clearing a gallery now sticks, folder placeholders no longer create Cloudinary folders and existing CKEditor embeds load their media. Malformed payloads fail the form instead of emptying the collection.
Browsing or uploading into a gallery now skips resources that are already in it and stops at the upload limit, and replacing a single image keeps its watermark.
…mote

The metadata is still saved locally, and the warning names the remote id so missing assets can be found.
Import order and missing function imports, no short ternary in the collection transformer, and intersection-typed provider mocks in the form type tests.
The multi-upload rewrite dropped the always-present remoteId input, so removing the media from a single field sent nothing and forms that keep the previous value on a missing field could not clear it. Dist rebuilt with Node 12.
Nothing in the Vue app reads the legacy label block, so keep it as on 4.0.
Items already in the field can no longer be picked again and use up the upload limit. Dist rebuilt with Node 12.
upload_limit 1 returns a single location, anything else a collection. Single fields need 'upload_limit' => 1, see UPGRADE.md.
Dist rebuilt with Node 12.
Nothing reads them; the interface uses the ngrm.edit.vue.* keys.
Load more now sits between the grid and the selection bar instead of covering it. Dist rebuilt with Node 12.
Keys like 'limit_reached': 'limit_reached' won over the English fallbacks in the Vue components, so CKEditor showed the raw key whenever /configuration did not send the translation. The isCollection flag is gone as well: form fields always submit a collection.
- Typing in a preview field only updates the state; the debounced handler sends one change event, so CKEditor no longer re-renders the widget after the first character.
- Bring back the CSS class and variation inputs for embeds and the preview.*_info tooltips.
- Gallery cards load previewUrl first and fall back to the original.
- Form fields always post collectionPayload, also with upload_limit 1; a limit of 1 only switches the picker to single select and makes new items replace the current one.
- An empty field shows "Select media" again.
- Labels for the per-item inputs, aria-labels for the reorder buttons, and vuedraggable options as props instead of the deprecated :options.
- "Create" opens the input on a real click. The menu is appended to <body>, so the click-outside handler cancelled the form; a click now only counts as outside when its mousedown also started outside the picker and its menu.
- Clearing the picker falls back to the configured parent folder instead of the root.
- Translate "Create folder in:", the root label and the create error, and read .detail before .message like the other requests.
Mario Ivančić added 8 commits November 14, 2026 15:30
The collectionPayload child holds "[]" for an empty field, which Symfony
does not consider empty, so the field and any form containing it were never
empty, eg. an optional embedded form got an object out of its empty_data.
The child now has an is_empty_callback which treats null, "" and an empty
JSON list as empty.
@mivancic

Copy link
Copy Markdown
Member

Thanks for the thorough review and for testing it in sklepex. I rebased onto current 4.0 first, so the overrides from #128 and the new position migration go in once.

As you suggested, the per-item alt text and caption in the form field are now the overrides, and they're carried through the payload, so a gallery save keeps them ("Carry alt text and caption overrides through the collection payload", "Edit the alt text and caption overrides in the form field inputs").

Two things follow from that which I decided myself, so please say if you'd rather have them differently:

  • The form field no longer writes alt text and caption to Cloudinary. With the per-item inputs being the overrides, nothing in the field edits them anymore, so altText and caption are left out of the payload and ignored if submitted. This also stops a stale page from writing an old alt text back. The CKEditor plugin still edits both ("Ignore the alt text and caption of the resource in the form field payload").
  • Tags still go to Cloudinary as before. For that the form calls a new RemoteResourceService::handleRemoteTagsUpdate() instead of handleRemoteUpdate(), because passing the stored alt text and caption back through handleRemoteUpdate() would turn a stored '' into null on every tag change.

Everything from "Must fix", "Smaller" and "Tests" is addressed, see the inline replies. In short:

  • The data is always a collection, also with upload_limit 1. The limit only affects the UI and the server-side count. Legacy 0 and the indexed shapes are gone.
  • A missing collectionPayload keeps the value, only [] clears it. The payload is rendered server-side with the current value.
  • Order is kept with a new position column on the location (Version040000).
  • CKEditor focus, embed fields and labels are fixed, and the translations come from one shared list.
  • The per-row inputs, the icon buttons and the folder pickers have labels or aria-labels.
  • The upload panel issues are fixed, including blocking submit while files are pending or uploading.
  • The field's errors, including the limit error, are now shown at the field (error_bubbling is false).
  • A resource missing in Cloudinary is now kept everywhere and a warning is logged, also in handleRemoteUpdate. It's in the CHANGELOG.
  • The new tests: persistence with Doctrine (POST, flush, reload), widget rendering, entry validation, missing payload, view after an invalid submit, /configuration keys.
  • A field without resources is now empty for Symfony, so an optional embedded form with only empty fields gets no object. We hit this in sklepex ("RemoteMediaType without resources is empty").
  • CHANGELOG, UPGRADE.md, FORM.md and FRONTEND.md are updated, and so is the PR description.

I also migrated sklepex to the new shape: all 11 single fields are collections now, moved with Doctrine migrations that I ran up, down and up on a copy of the dev database. Akeneo stores the attribute values as lists.

Still open:

  • The Norwegian strings still need a check by a native speaker. I have a list with the English next to each string.
  • We'll ask Netgen for a netgen/layouts-remote-media release that allows ^4.0.
  • The fixed folder option is enforced in the UI only. Enforcing it on the upload endpoint goes into a separate ticket.

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I re-tested 3b7dc1f7 in the Symfony 7.4 test app, with all three fields mapped as collections like in FORM.md, and in sklepex with CKEditor 5. I also ran Version040000 up, down and up again on MySQL. CI is green.

Great work, everything from the first round is fixed and the tests are much better. A few things before merge.

Must fix

  • Alt text and caption: I'd rather keep the cloud values editable in the form field, next to the overrides, like in CKEditor. See inline on Preview.vue and RemoteMediaTransformer. FORM.md, UPGRADE.md and the CHANGELOG need to follow.

Should fix

  • The submit block stops Cancel buttons too, and in a hidden tab it fails silently. See inline.
  • Docs: the migration order in UPGRADE.md, the location_id claim, and a few missing CHANGELOG lines. See inline.

Smaller

  • A few upload panel items, two hr strings, the treeselect texts and loadFromRemote() on a rejected payload. See inline.
  • INSTALL.md still says composer require netgen/remote-media-bundle:^3.0.

Enforcing the fixed folder on the endpoint in a separate ticket is fine. I'll rebase platform (#125) once this is in.

Comment thread frontend/src/components/Preview.vue Outdated
class="media-caption-override data"
>
</div>
<!-- Alt text and caption of this location; in form fields they are the only alt text and caption inputs -->

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd keep the cloud alt text and caption editable here too, with the overrides next to them, like in CKEditor. Editors edit the cloud values from the form today, and the overrides are for per-place exceptions. So altText and caption go back into the payload.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To be clear, since my first-round comment ("Per-item alt and caption should be the overrides") was badly worded: I meant carry the overrides through the payload as well, not replace the cloud inputs with them. Sorry for the extra round.

The rule is simple: the form field and CKEditor must behave the same. The cloud alt text and caption stay editable in both, and the overrides are just that, an optional override per location on top of them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done. The cloud alt text and caption inputs are back in the form field, with the override inputs next to them, the same as in CKEditor. altText and caption are back in the payload. FORM.md, UPGRADE.md and the CHANGELOG are updated.

// never changed by the form field, whatever the payload carries.
// A resource that is gone from the remote is kept, the service logs it.
$tags = $value['tags'] ?? [];
$this->service->handleRemoteTagsUpdate($remoteResource, is_array($tags) ? $tags : []);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

With the cloud fields back, this goes through handleRemoteUpdate() again. On your two points:

  • '' turning into null on a tag change: normalise empty values the same way when comparing and storing, instead of working around it here;
  • a stale page writing an old alt text back is the same last-write-wins as any other field, I'm fine with that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done, the form calls handleRemoteUpdate() again and handleRemoteTagsUpdate() is removed. Empty values are already normalised the same way when comparing and when storing, so nothing else changes there.

// and no response. A slow but moving upload of a big file is never cut off.
const UPLOAD_IDLE_TIMEOUT_MS = 180000;
const UPLOAD_TIMEOUT_REASON = 'ngrm-upload-timeout';
const SUBMIT_CONTROL_SELECTOR = 'button:not([type]), button[type=submit], input[type=submit], input[type=image]';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This also catches Cancel and Delete draft submit buttons (Ibexa content edit has both), so with a pending row the editor can't leave without removing it first. Skip controls with formnovalidate, maybe add a data-ngrm-skip-submit-block opt-out, and document it next to ngrm-submit-blocked.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done. Buttons with formnovalidate or data-ngrm-skip-submit-block are never blocked, for both the click and the submit event. It's documented next to ngrm-submit-blocked in UPGRADE.md and in the CHANGELOG.

}));

this.$nextTick(() => {
if (this.$refs.submitBlocked) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If the field is in an inactive tab (Sylius product edit), the message renders hidden and scrollIntoView() does nothing, so Save just doesn't react. When this.$el.offsetParent === null, show the message somewhere visible too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done. If the field is hidden (offsetParent === null), the message is also shown at the top of the page for a few seconds.

document.addEventListener('submit', this.formSubmitListener, true);
document.addEventListener('click', this.submitClickListener, true);
},
beforeDestroy() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Cancel the running uploads here. In CKEditor a debounced change re-renders the widget while a file uploads, the request still finishes, and the resource stays in Cloudinary without being added.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done. Running uploads are cancelled when the panel is destroyed, and nothing is emitted after that. A request the server already received can still finish there.

Comment thread frontend/package.json Outdated
"portal-vue": "^2.1.7",
"pretty-bytes": "^5.6.0",
"regenerator-runtime": "^0.14.1",
"vue": "^2.6.10",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

^2.7.16, and the same for vue-template-compiler, so the range matches the lock.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done, ^2.7.16 for both.

Comment thread lib/Form/Type/RemoteMediaType.php Outdated
}

try {
return $this->provider->loadFromRemote($remoteId);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This runs for every unknown remote ID of a rejected payload, and a rejected payload has no limit by definition. 200 made-up IDs mean 200 Admin API calls on one render. Use only loadByRemoteId() in the view path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done. The view path uses only loadByRemoteId() now, and there's a test that it doesn't call the remote. A resource picked in the media browser that isn't stored locally yet is left out of that view, FORM.md says so.

Comment thread docs/UPGRADE.md
php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml
```

* The migration adds the nullable `position` column to `ngrm_remote_resource_location`. The form stores the order of a field's resources in it. Existing locations have no position.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Please say that Version040000 runs before doctrine:migrations:diff for the OneToOne migration below, and that the diff needs the --filter-expression from the 3.0.1 section. Otherwise the diff also adds position, and Version040000 then fails with "Duplicate column name 'position'". The other way round, the example's SET l.position = 0 fails if Version040000 never ran.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done. The Database section and the OneToOne section now say to run Version040000 before the diff and to pass the --filter-expression, with both failure cases.

Comment thread docs/UPGRADE.md Outdated
### Templates

* `@NetgenRemoteMedia/form/remote_media_type.html.twig` renders the `collectionPayload` field instead of the `locationId` and `source` fields.
* `@NetgenRemoteMedia/app/interactions.html.twig` takes three new parameters: `locations` (a list of `RemoteResourceLocation` objects), `upload_limit` and `location_source`. `upload_limit` defaults to `1`, so templates which include it with `location_id` keep working with one resource. The `variation_settings_json` parameter is removed, crop settings are read from the locations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Only half true: it renders, but in a form field the widget posts only collectionPayload. A template that passes location_id and the old input_fields without collectionPayload never saves. Reword it, or drop the location_id fallback. Same in CHANGELOG line 14.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Dropped the fallback, interactions.html.twig no longer takes location_id. UPGRADE.md and the CHANGELOG say to pass locations and add collectionPayload to input_fields. The Ibexa and Layouts integrations move to locations in their 4.0 releases.

Comment thread docs/CHANGELOG.md Outdated
* the frontend lock file is re-resolved, which upgrades Vue from 2.6 to 2.7, `vue-select` from 3.2 to 3.20 and `@babel/core` from 7.6 to 7.28
* `regenerator-runtime` is a direct frontend dependency, the re-resolved Babel needs it
* the alt text and caption inputs of the form field edit the overrides of the location (`altTextOverride` and `captionOverride`), one alt text and one caption input per item, the form field doesn't change the alt text and caption stored on the cloud anymore, `altText` and `caption` are not part of `collectionPayload` and are ignored if submitted, the CKEditor 5 plugin still shows both, see [form documentation](FORM.md#alt-text-and-caption-overrides)
* `RemoteResourceService::handleRemoteTagsUpdate()` updates only the tags of a resource on the remote, `RemoteMediaType` uses it instead of `handleRemoteUpdate()`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Missing: tags are compared and stored sorted, and handleRemoteUpdate() stores an empty alt text or caption as null. Line 41 changes anyway with the cloud fields back; please split it into single-clause bullets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added both, as single-clause bullets. The old line 41 is removed, since the form edits the cloud values as it did in 3.1.

@mivancic

Copy link
Copy Markdown
Member

Thanks for re-testing it, and no problem about the extra round.

  • The form field edits the cloud alt text and caption again, with the overrides next to them, like CKEditor. Both go through the payload, and the form uses handleRemoteUpdate() again. handleRemoteTagsUpdate() is gone.
  • Everything else from "Should fix" and "Smaller" is fixed, see inline. The location_id fallback is removed, and INSTALL.md now says ^4.0.

Still open, as before: the Norwegian check by a native speaker, the netgen/layouts-remote-media release for ^4.0, and the folder enforcement ticket.

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I re-tested 0f336616 in the Symfony 7.4 test app and in sklepex with CKEditor 5. CI is green.

Thanks, everything from the second round is fixed. One thing before merge.

Should fix

  • The same resource in two fields of one form loses cloud alt text and caption edits. See inline on RemoteMediaTransformer.

I'll fix the null alt and caption on Cloudinary SDK 3 in platform (#125).

}
}
// A resource that is gone from the remote is kept, the service logs it.
$this->service->handleRemoteUpdate($remoteResource, $value);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If the same resource is in two fields of the form (Image and Gallery in my test), each field posts its own altText and caption, and the last one wins. I changed the alt text in Image only, Gallery posted the old empty value, and it ended up null in the DB and in Cloudinary. Only write a cloud value when the editor changed it, eg. send the loaded value along in the entry and compare with that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in 45c22db, dist rebuilt in 02ab909.

Each payload entry now has loaded: the alt text, caption and tags the widget loaded. The transformer writes only the values that differ from it. The others keep the resource's current value, so Gallery no longer overwrites the alt text changed in Image. A rejected submission keeps loaded too, so the edits still count after the form is shown again. An entry without loaded works as before.

Tests cover Image and Gallery on the same resource, with a change in one field and with changes in both. FORM.md and the changelog describe loaded.

@mivancic

Copy link
Copy Markdown
Member

Thanks! The alt text and caption from two fields are fixed, see the inline reply. And thanks for taking the null alt and caption on SDK 3 in #125.

While testing it I found one more bug and fixed it in 554971f: the Cloudinary factory read the alt text from custom.alt_text, but the API returns it as custom.alt, which is the key we write. So loadFromRemote() always returned the alt text as null. alt_text is still read for older resources.

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I re-tested 554971ff in the Symfony 7.4 test app. CI is green, and the two fields on one resource work now, also with a stale tab.

One more thing before merge.

Should fix

  • After a rejected submit, an alt text change in a valid field is lost on the next save. See inline on RemoteMediaType.

Comment thread lib/Form/Type/RemoteMediaType.php Outdated

return [
'remote_media_locations' => is_iterable($data) ? RemoteMediaCollectionTransformer::sortByPosition($data) : [],
'remote_media_loaded_values' => [],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is also the path for a valid field in an invalid form, and then the widget takes the edited values as loaded. I changed the alt text in Image and made Gallery go over the limit: 422, and the next Save writes nothing for Image, because altText now equals loaded. The rejected request had already pushed the new alt text to Cloudinary, so DB and Cloudinary stay out of sync. Take loaded from the submitted payload here too whenever the form was submitted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in a39205e. When the form was submitted, the view now takes loaded from the submitted payload for a valid field too, matched to the locations by remote ID. So after the 422 the widget still sends the Image alt text as a change, and the next save writes it to the DB. The test covers a valid Image field with Gallery over the limit.

@mivancic

Copy link
Copy Markdown
Member

Thanks, fixed, see the inline reply.

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I re-tested a39205e8 in the Symfony 7.4 test app. A valid field in a rejected form keeps its alt text change now, and after the next save DB and Cloudinary have the same value. Two fields on one resource still work, and CI is green.

Nice work, and thanks for sticking with it through all the rounds. Good to merge from my side.

I'll take the null alt text and caption on SDK 3 in #125 after this is merged.

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.

2 participants