adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
733 stars 741 forks source link

Image Component: Fileupload widget no more showing thumbnail, Clear options unavailable #101

Closed tnebe closed 6 years ago

tnebe commented 6 years ago

When using AEM Core WCM Image component with provided dialog, it only accepts rasterized images by mimeTypes change of @kwin in https://github.com/Adobe-Marketing-Cloud/aem-core-wcm-components/pull/32/files

image

With this change, the fileupload widget is no more able to create a thumbnail, as the according script only accepts imageas mimeType in /libs/cq/gui/components/authoring/dialog/fileupload/render.jsp [AEM 6.3.0.2]:

/* L214 */ boolean hasImageMimeType = Arrays.asList(mimeTypes).contains("image");
/* L215 */ ...

According Daycare ticket has been raised and already confimed by Adobe as a product bug in Ticket ID 139755 and will now be fixed with AEM 6.4. The change could be applied earlier by overlaying /libs/cq/gui/components/authoring/dialog/fileupload/render.jsp and will look like:

...
         Node thumbnailNode = res.adaptTo(Node.class);
         long cacheKiller = UIHelper.getCacheKiller(thumbnailNode);

-        boolean hasImageMimeType = Arrays.asList(mimeTypes).contains("image");
-        boolean hasVideoMimeType = Arrays.asList(mimeTypes).contains("video");
+        boolean hasImageLikeMimeType = false;
+        boolean hasVideoLikeMimeType = false;

+        for (String mimeType : mimeTypes) {
+            hasImageLikeMimeType = hasImageLikeMimeType || mimeType.startsWith("image");
+            hasVideoLikeMimeType = hasVideoLikeMimeType || mimeType.startsWith("video");
+        }
+
         if (assetResource != null || StringUtils.isNotEmpty(resourceFileName)) {
-            if (hasImageMimeType || hasVideoMimeType) {
+            if (hasImageLikeMimeType || hasVideoLikeMimeType) {
                 if (assetResource != null) {
                     // For a DAM image reference: get a web rendition
                     // For a DAM video reference: get a thumbnail rendition
                     Asset asset = assetResource.adaptTo(Asset.class);
                     if (asset != null) {
                         final Rendition rendition;

-                        if (hasVideoMimeType) {
+                        if (hasVideoLikeMimeType) {
                             rendition = asset.getRendition(THUMBNAIL_RENDITION_NAME);
                         } else {
                             rendition = asset.getRendition(new WCMRenditionPicker());
...

Nevertheless raising an issue here also, as this is a bad behaviour coming with introducing WCM Core Image Component and like to discuss possible solutions.

Maybe there is an approach for accepting any type of image because SVG´s are not able to use with current solution or just adding a hint in the image component README file.

Thanks!

henrykuijpers commented 6 years ago

Actually, letting the "mimeTypes"-property still include "image" as well, should not really be an issue. WDYT?

tnebe commented 6 years ago

I think the widget has been limited to accept only bitmap images because of Core Image Component with different widths can only used for those images. MimeType image would also allow image/svg+xml to be included which is not supported.

henrykuijpers commented 6 years ago

Eehhrrr, yes, indeed. These components still have to work on aem versions lower than 6.4...

bpauli commented 6 years ago

For AEM 6.3 this issue will be fixed with the Cumulative Fix Pack 6.3.2.2, which is planned for end of June.

NPR-23156