FORMS-26424-Add Next Gen Dynamic Media (NGDM) support to the StaticImage component - #1965
pankaj-parashar wants to merge 5 commits into
Conversation
Ports the NGDM asset support from adobe/aem-core-wcm-components#2481 to the Adaptive Forms StaticImage (form/image v1) component. When the fileReference is an NGDM asset (/urn:...) and the NextGenDynamicMediaConfig OSGi service is enabled, the delivery URL is built directly instead of resolving a DAM rendition. Bumps aem-sdk-api to 2023.9.13665 to pick up the NextGenDynamicMediaConfig API, and enables the NGDM asset picker on the component's file upload dialog field. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Accessibility Violations Found
|
1 similar comment
Accessibility Violations Found
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| private static final String PATH_PLACEHOLDER_SEO_NAME = "{seo-name}"; | ||
| private static final String PATH_PLACEHOLDER_FORMAT = "{format}"; | ||
| private static final String DEFAULT_NGDM_ASSET_EXTENSION = "jpg"; | ||
| private static final int DEFAULT_NGDM_ASSET_WIDTH = 640; |
There was a problem hiding this comment.
why is 640 default and jpg default ?
There was a problem hiding this comment.
Hi @rismehta ,
If we do not send any width the Dynamic Media Open API sends the default width of 1024, which dominates the screen and this is how it looks:

But with width default value = 640 , the image renders at a size that coexists properly with the rest of the form's components.

Since the authoring canvas has no independent scaling constraint, the size of the image canbe managed by theme and styling, We can keep this default to 640
There was a problem hiding this comment.
I mean how did we choose this magic numbers ? is this based on some customer data or existing proven patterns ?
There was a problem hiding this comment.
@rismehta , this was referred from Core Component Image - Dynamic Integration implementation.
https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/ImageImpl.java#L78
There was a problem hiding this comment.
widely-used breakpoint values — e.g. Tailwind CSS's default breakpoints are sm=640px, md=768px, lg=1024px, xl=1280px, 2xl=1536px.
In responsive-image-serving conventions specifically (Cloudinary/Imgix-style breakpoint guides), 640 and 1024 are common rungs in a typical image-width ladder
- Extract Next Gen Dynamic Media (NGDM) URL-resolution logic out of StaticImageImpl into a shared NgdmImageUtils class - Add a Sling Model JSON-exporter test proving the resolved NGDM delivery URL is exposed as "value" and fd:repoPath is correctly absent - Fix multi-dot seo-name filenames (e.g. "product.hero.png") resolving to the wrong delivery URL/extension by splitting on the last dot, not the first - Tighten isNgdmImageReference() to require a non-empty asset-id and seo-name segment, avoiding a NoSuchElementException on malformed references - Mark com.adobe.cq.ui.wcm.commons.config as an optional OSGi import so the bundle still resolves on installations without this Cloud Service API
- Add FT_NGDM_IMAGE_PICKER (FT_FORMS-26424) constant, following the existing FeatureToggleConstants pattern - Split the Image dialog's file widget into two mutually-exclusive variants gated by granite:rendercondition/featuretoggle: NGDM picker enabled shows the Pick (Local/Remote) UI, disabled shows the original Browse Assets/Upload UI - Gate StaticImageImpl's NGDM URL resolution and fd:repoPath exclusion behind the same toggle via ComponentUtils.isToggleEnabled(), so a saved NGDM reference is treated as a plain fileReference when the toggle is off - Add toggle-enabled/disabled test coverage, following the same System.setProperty/@AfterEach pattern already used in FragmentImplTest
Runs the project's eclipse-formatter.xml rules over NgdmImageUtils.java and its test, which had not been formatted before commit and were failing the verify-code-formatting build step on both Java 11 and 21 CI jobs. Whitespace-only change, no logic changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tream changes and fix stale exporter-json/recaptcha CI check
Accessibility Violations Found
|
3 similar comments
Accessibility Violations Found
|
Accessibility Violations Found
|
Accessibility Violations Found
|
| * Utility methods for resolving Next Gen Dynamic Media (NGDM) asset references | ||
| * (of the form {@code /urn:aaid:aem:<asset-id>/<seo-name>.<format>}) into delivery URLs. | ||
| */ | ||
| public final class NgdmImageUtils { |
There was a problem hiding this comment.
Why is utils inside model folder ? Can you place this in appropriate package
There was a problem hiding this comment.
Moved it to bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/NgdmImageUtils.java
| // must have a non-empty asset-id segment and a non-empty seo-name segment, i.e. | ||
| // "/urn:<asset-id>/<seo-name>[.<format>]", otherwise buildNgdmImageSrc() has nothing to parse. | ||
| String withoutLeadingSlash = fileReference.substring(1); | ||
| int slashIndex = withoutLeadingSlash.indexOf('/'); |
| */ | ||
| public static String buildNgdmImageSrc(String fileReference, NextGenDynamicMediaConfig nextGenDynamicMediaConfig) { | ||
| String withoutLeadingSlash = fileReference.substring(1); | ||
| int slashIndex = withoutLeadingSlash.indexOf('/'); |
There was a problem hiding this comment.
Make use of StringUtils library for string related operations
| .replace(PATH_PLACEHOLDER_SEO_NAME, assetName) | ||
| .replace(PATH_PLACEHOLDER_FORMAT, assetExtension); | ||
|
|
||
| return "https://" + nextGenDynamicMediaConfig.getRepositoryId() + imageDeliveryPath |
There was a problem hiding this comment.
Why we have hardcoded this to https, is this configurable ? Should this come via cloud configuration ?
There was a problem hiding this comment.
Hi @rismehta ,
- this code is based on aem-core-wcm-components's implementation of Dynamic Media Integration. Hence copied the same pattern of hardcoding "https" : [1][2]
- NextGenDynamicMediaConfig interface (from aem-sdk-api) does not expose any schema/protocol , which we could have used
- the official documentation of Dynamic Media [3], states it requires https to function
- The integration we do in cloud manager / confgmgr to connect to dynamic media server does not take any protocol input. The server url is provided as follows : delivery-pxxxxx-eyyyyyy.adobeaemcloud.com
Hence can't configure from here. [4]
Therefore we kept it as is.
[1]https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMImageURIBuilder.java#L137
[2]https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/ImageImpl.java#L267
[3] https://experienceleague.adobe.com/en/docs/experience-manager-core-components/using/developing/remote-assets#https
[4] https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/dynamicmedia/dynamic-media-open-apis/integrate-remote-approved-assets-with-sites#pre-requisites-sites-integration
| * which falls back to the original Browse Assets/Upload UI in that case. | ||
| */ | ||
| private boolean isNgdmReferenceAndFeatureEnabled() { | ||
| return ComponentUtils.isToggleEnabled(FeatureToggleConstants.FT_NGDM_IMAGE_PICKER) |
There was a problem hiding this comment.
Since this is system toggle, you also need to enable this in aemds far
rismehta
left a comment
There was a problem hiding this comment.
check comments, create PR against dev
|
Addressed the comments on the dev PR . Closing this one. #1989 |
Ports the NGDM asset support from adobe/aem-core-wcm-components#2481 to the Adaptive Forms StaticImage (form/image v1) component. When the fileReference is an NGDM asset (/urn:...) and the NextGenDynamicMediaConfig OSGi service is enabled, the delivery URL is built directly instead of resolving a DAM rendition. Bumps aem-sdk-api to 2023.9.13665 to pick up the NextGenDynamicMediaConfig API, and enables the NGDM asset picker on the component's file upload dialog field.
changes behind : FT_FORMS-26424
Description
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: