decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.96k stars 3.05k forks source link

feat: remove deleted image from content #7310

Open hip3r opened 1 month ago

hip3r commented 1 month ago

Summary

Added configuration option for removing deleted image from content. Instead of saving empty string. closes #7120 closes #7186

I wasn't sure that this should be working by default, that's why I extended cms configuration with new option remove_empty_image_field. conected PR for docs will follow.

Implementation is overlapping with logic for #3314 , which inserts default values for all removed entries. The same reason prevented me from saving image value as null or undefined instead of empty string.

Test plan

BEFORE: image

AFTER: image

Checklist

Please add a x inside each checkbox:

A picture of a cute animal (not mandatory but encouraged) photo_2024-10-22_10-19-18

martinjagodic commented 1 week ago

We also have a chance to solve two problems in one go here and extend this to other field types

We don't have to do this in this PR, but I would anticipate such a feature in config. So instead of remove_empty_image_field we could have remove_empty_fields, which would accept an array of widgets?