feat: derive image field ID from focal point field ID for dynamic fie…[]
Dynamic Image Field Association for Focal Point App
- Fixes #9898
Purpose
The Image Focal Point app was previously hardcoded to only work with a sibling field named "image". This limitation made it difficult to use the app with multiple image fields in the same content type. This change enables more flexible field configurations by dynamically deriving the target image field ID from the focal point field's own ID.
Approach
We implemented a new deriveImageFieldId utility function that follows a consistent naming pattern:
focalPoint→image(maintains backward compatibility)focalPointLarge→imageLargefocalPointSomeThing→imageSomeThing
All references to the hardcoded IMAGE_FIELD_ID constant were updated to use this dynamic approach, while ensuring backward compatibility for existing implementations.
Testing steps
- Add a field of type JSON with ID "focalPoint" and configure the focal point app - verify it works with an "image" field
- Add a field of type JSON with ID "focalPointLarge" and configure the focal point app - verify it works with an "imageLarge" field
- Add a field of type JSON with ID "focalPointCustom" and configure the focal point app - verify it works with an "imageCustom" field
- Check that error handling shows the correct field ID in error messages when target image fields are not found
Breaking Changes
None. This change is fully backward compatible:
- Existing fields named exactly "focalPoint" will continue to associate with "image" fields
- The default fallback remains "image" for any unexpected field naming patterns
- No configuration changes are required for existing implementations
Dependencies and/or References
N/A
Deployment
Standard deployment process applies; no special deployment steps required.