You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clearing an Image Cropper inside a block stores "null" and leaves the uploaded file behind #110
A follow-up to #102 / #103 (thanks for the quick fix). With 4.0.5 on Umbraco 17.7.1, clearing an Image Cropper inside a content block has two side effects:
The nested value is stored as the JSON string "null" instead of null. After that, Actions → Publish… on the page fails with a 500: Could not parse editor value to a ImageCropperValue object.
The uploaded file is not deleted from the media file system.
Root cause
In ContentBlocksValueEditor.FromEditor, each nested value goes through:
prop.Value is the incoming editor value, not the stored one. The Image Cropper's FromEditor uses currentValue to find the existing file, so it sees no current file. It then skips the delete and falls through to its "unchanged" path, which serializes the null value to the string "null". That last part is also an Umbraco bug, reported in umbraco/Umbraco-CMS#24335.
Umbraco's own block editors pass the stored nested value (BlockValuePropertyValueEditorBase.MapBlockItemDataFromEditor matches edited and current items by key and values by alias). So in core, the same clear deletes the file and stores null.
Steps to reproduce
Create an element type with a Textstring and a non-mandatory Image Cropper, plus a content block definition for it.
Add the block to a page, upload an image, and Save and publish.
Clear file(s), then Save and publish. The stored nested value is {"editorAlias":"Umbraco.ImageCropper",...,"alias":"image","value":"null"}, and the media file still exists.
Actions → Publish… returns a 500.
Suggested fix
Pass the stored nested value as currentValue, matching blocks by id and values by alias, the way core does. Happy to open a PR.
I just merged your PR as it seemed to work, however just now I was testing it again and I get the exception Could not parse editor value to a ImageCropperValue object in other very similar scenarios. It seems the fix is not complete yet. Can you check if you see the same behavior on your end?
After page reload:
This basically follows your reproduction steps, but then reloads the page. After that it's no longer possible to publish the page (with the empty cropper).
Hi Daniel, thanks for testing it further. I could reproduce both cases on my end with current master (Umbraco 17.7.1), and they also happen in exactly the same way with Umbraco's own Block List, so they come from Umbraco's Image Cropper rather than from Content Blocks. When the cropper is empty and there's no existing file (because the earlier save already deleted it, or the image was never saved), Umbraco stores the text "null", and the publish step then can't parse it. It's the issue I mentioned at the end of the PR description, umbraco/Umbraco-CMS#24335.
The fix is in umbraco/Umbraco-CMS#24336, which has been approved and is labelled for 17.10.0. With that change applied, both of your scenarios publish fine, for Content Blocks and Block List, and pages that already have "null" stored can be published again without a re-save.
In case you'd like to try it yourself, this is how I tested it:
1. Build Umbraco.Infrastructure 17.7.1 with the fix
(On Windows, git config core.longpaths true may be needed. The two commits apply cleanly on 17.7.1; on 17.7.2 and later the file has changed.)
2. Swap it into a 17.7.1 test site running Content Blocks master. Stop the site, back up bin/.../Umbraco.Infrastructure.dll, copy in the one from src/Umbraco.Infrastructure/bin/Release/net10.0/, and start the site again. The assembly version is the same (17.7.1.0), so nothing else needs changing. Put the backup back afterwards.
3. Run your two scenarios again, on a page with a content block that has a non-mandatory Image Cropper:
Pick an image, Save and publish, remove it, Save and publish, reload (F5), Save and publish. This now succeeds and the cropper is stored as null.
On a page where the image was never saved, pick an image, remove it, and Save and publish. This now succeeds as well.
Optional: on a page that already failed before the swap (it has "null" stored), use Actions → Publish… without changing anything. It now publishes.
With the original DLL, the same steps on a Block List with the same element type fail in the same way.
If you'd like something in Content Blocks before 17.10.0, I could open a small PR that stores null when a nested editor returns the text "null". Happy to go with whatever you prefer.
I see. No need for a follow-up PR if it will be fixed by Umbraco itself at some point; although it will take some time considering 17.10.0 is scheduled for January 21st, 2027, more than 2 months from now.
Regardless, if an Image Cropper now behaves the same in this package as in e.g. Umbraco.BlockList then it's OK. It does make the Image Cropper basically unusable until 17.10.0 since you cannot publish an empty value in many cases.
I will close this one again and will release 4.0.7 with this (partial) fix today.
Activity
PerplexDaniel commentedon Nov 11, 2026
@talhamalik4025
I just merged your PR as it seemed to work, however just now I was testing it again and I get the exception
Could not parse editor value to a ImageCropperValue objectin other very similar scenarios. It seems the fix is not complete yet. Can you check if you see the same behavior on your end?After page reload:
This basically follows your reproduction steps, but then reloads the page. After that it's no longer possible to publish the page (with the empty cropper).
Without saving and publishing a picked image:
talhamalik4025 commentedon Nov 11, 2026
Hi Daniel, thanks for testing it further. I could reproduce both cases on my end with current master (Umbraco 17.7.1), and they also happen in exactly the same way with Umbraco's own Block List, so they come from Umbraco's Image Cropper rather than from Content Blocks. When the cropper is empty and there's no existing file (because the earlier save already deleted it, or the image was never saved), Umbraco stores the text
"null", and the publish step then can't parse it. It's the issue I mentioned at the end of the PR description, umbraco/Umbraco-CMS#24335.The fix is in umbraco/Umbraco-CMS#24336, which has been approved and is labelled for 17.10.0. With that change applied, both of your scenarios publish fine, for Content Blocks and Block List, and pages that already have
"null"stored can be published again without a re-save.In case you'd like to try it yourself, this is how I tested it:
1. Build Umbraco.Infrastructure 17.7.1 with the fix
(On Windows,
git config core.longpaths truemay be needed. The two commits apply cleanly on 17.7.1; on 17.7.2 and later the file has changed.)2. Swap it into a 17.7.1 test site running Content Blocks master. Stop the site, back up
bin/.../Umbraco.Infrastructure.dll, copy in the one fromsrc/Umbraco.Infrastructure/bin/Release/net10.0/, and start the site again. The assembly version is the same (17.7.1.0), so nothing else needs changing. Put the backup back afterwards.3. Run your two scenarios again, on a page with a content block that has a non-mandatory Image Cropper:
null."null"stored), use Actions → Publish… without changing anything. It now publishes.With the original DLL, the same steps on a Block List with the same element type fail in the same way.
If you'd like something in Content Blocks before 17.10.0, I could open a small PR that stores
nullwhen a nested editor returns the text"null". Happy to go with whatever you prefer.PerplexDaniel commentedon Nov 11, 2026
I see. No need for a follow-up PR if it will be fixed by Umbraco itself at some point; although it will take some time considering 17.10.0 is scheduled for January 21st, 2027, more than 2 months from now.
Regardless, if an Image Cropper now behaves the same in this package as in e.g. Umbraco.BlockList then it's OK. It does make the Image Cropper basically unusable until 17.10.0 since you cannot publish an empty value in many cases.
I will close this one again and will release 4.0.7 with this (partial) fix today.