Fix saving Image Cropper and File Upload editors inside a block#103
Open
talhamalik4025 wants to merge 1 commit into
Open
Fix saving Image Cropper and File Upload editors inside a block#103talhamalik4025 wants to merge 1 commit into
talhamalik4025 wants to merge 1 commit into
Conversation
…ad) inside a block The inner ContentPropertyData was created without a ContentKey or PropertyTypeKey, so property editors that store files against the content key (Image Cropper, MediaPicker3, File Upload) received Guid.Empty and threw "Invalid content key" on save. Set both keys before calling the inner FromEditor, mirroring Umbraco core's BlockValuePropertyValueEditorBase. Fixes PerplexDigital#102
Member
|
Thanks @talhamalik4025 for your detailed issue report and the PR. I'm very busy today but will have a look early next week. The code looks good but I also need to verify it works as intended. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #102.
If you put an Umbraco Image Cropper or File Upload editor on a block's element type, saving the page fails with "Invalid content key". In
ContentBlocksValueEditor.FromEditorthe innerContentPropertyDatais created without aContentKeyorPropertyTypeKey, so both default toGuid.Empty.ImageCropperPropertyValueEditorandFileUploadPropertyValueEditorboth explicitly throw"Invalid content key"in that case, and need the key to build the media storage path. Editors that only store a reference (e.g. Media Picker v3) ignore the two keys, which is why everything else saves fine.This sets both keys before calling the inner
FromEditor, taking the content key from the incomingeditorValue– the same approach Umbraco core takes inBlockValuePropertyValueEditorBase.MapBlockItemDataFromEditor(umbraco/Umbraco-CMS#18976).Verified on Umbraco 17: with this change the Image Cropper saves correctly inside a block (the file is stored against the content), and reference-based editors like Media Picker are unaffected (Media Picker stores a media-library reference, not a file on the content). File Upload uses the same content-key mechanism as the Image Cropper – the identical
"Invalid content key"guard – so it's covered by the same fix.