Add placeholder flag when image widget has empty _image array#5228
Add placeholder flag when image widget has empty _image array#5228skosarin wants to merge 7 commits intoapostrophecms:mainfrom
Conversation
Extends the load method to set aposPlaceholder to true when a widget has an empty _image array, ensuring proper placeholder display for image widgets without selected images. Issue occurs when an already selected image is archived and a user edits the page with said image-widget
Adds changelog entry documenting the fix for image widgets failing to display placeholders when selected images are archived, resulting in empty _image relationships.
This reverts commit 3b1a988.
boutell
left a comment
There was a problem hiding this comment.
Thanks for contributing this. I see the reasoning behind it and I do see how it would be useful to editors. However this would also cause it to appear for the public, which is never intended to occur. So it wouldn't be suitable in its current form.
However, checking for req.query.aposEdit === '1' first might resolve that. I suggest you try that and see if it ensures the placeholder is displayed only when editing and not previewing or just a member of the public viewing the site.
Adds early return in load method to skip placeholder processing when aposEdit query parameter is not set to '1', preventing unnecessary placeholder logic execution outside of edit context.
|
at least on my local, it behaves as desired -- no placeholder image when in preview/published, but placeholder appears on edit, and no page error occurs |
|
OK fair, we will QA it directly to see if any further change is actually needed cc @BoDonkey |
|
Oh excuse me, I see you did add the change! Your comment makes more sense now 👍 |
Summary
Fixes an issue where the image widget could incorrectly have aposPlaceholder: false even when its _image relationship is empty. This ensures the placeholder displays correctly for image widgets with no selected image.
This situation can occur when a previously selected image is archived, and an editor later opens the page containing that image widget.
What are the specific steps to test this change?
What kind of change does this PR introduce?
Make sure the PR fulfills these requirements:
Other information:
Normalizes widget state during widget loading to prevent aposPlaceholder from remaining false when _image is an empty array. This avoids a broken/non-placeholder UI state after archiving images previously selected by an image widget.