I added the mimeTypes as " images/png, images/gif" etc.. in crdxe. But once i upload and edit, i cant view the preview in dialog box.
So i analyse the render.jsp file coming under /libs/cq/gui/components/authoring/dialog/fileupload and what i understood is that the issue occurred from hasImageMimeType and hasVideoMimeType declaration.
I changed the array list from Arrays.asList(mimeTypes).contains("image"); to Arrays.asList(mimeTypes).toString().indexOf("image"); and its working. Could you please check is this relevant one or any property declaration issue.
![Screen Shot 2018-01-22 at 3.39.11 PM.png Screen Shot 2018-01-22 at 3.39.11 PM.png](/t5/image/serverpage/image-id/9459i1367CD8F636924A3/image-size/large?v=v2&px=999)
Current Code
boolean hasImageMimeType = Arrays.asList(mimeTypes).contains("image");
boolean hasVideoMimeType = Arrays.asList(mimeTypes).contains("video");
if (assetResource != null || StringUtils.isNotEmpty(resourceFileName)) {
if (hasImageMimeType || hasVideoMimeType) {
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) {
rendition = asset.getRendition(THUMBNAIL_RENDITION_NAME);
} else {
rendition = asset.getRendition(new WCMRenditionPicker());
}
if (rendition != null) {
thumbnailSrc = rendition.getPath() + "?ch_ck=" + cacheKiller;
}
isAssetFromDAM = true;
} else {
// image has been uploaded
thumbnailSrc = thumbnailSrc + THUMBNAIL_SUFFIX + "?ch_ck=" + cacheKiller;
}
}
}
// We have a resource and/or a title to display
thumbnailTitle = resourceFileName;
}
My Changes here
int hasImageMimeType = Arrays.asList(mimeTypes).toString().indexOf("image");
int hasVideoMimeType = Arrays.asList(mimeTypes).toString().indexOf("video");
if (assetResource != null || StringUtils.isNotEmpty(resourceFileName)) {
if (hasImageMimeType == 1 || hasVideoMimeType == 1) {
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 == 1) {
rendition = asset.getRendition(THUMBNAIL_RENDITION_NAME);
} else {
rendition = asset.getRendition(new WCMRenditionPicker());
}
if (rendition != null) {
thumbnailSrc = rendition.getPath() + "?ch_ck=" + cacheKiller;
}
isAssetFromDAM = true;
} else {
// image has been uploaded
thumbnailSrc = thumbnailSrc + THUMBNAIL_SUFFIX + "?ch_ck=" + cacheKiller;
}
}
}
// We have a resource and/or a title to display
thumbnailTitle = resourceFileName;
}