AEM Hide Images in Asset finder for NDA/Secret projects


In order to hide images from asset finder we need to overwrite below file to /apps

/libs/cq/gui/components/authoring/assetfinder/asset/asset.jsp

We can create a folder and any images available under that folder can be ignored while displaying in asset finder tab using below code

boolean showimage = true;

if(imgSrc.indexOf("/internal_image/") > -1) {

    showimage = false;
}
if(request.getQueryString().indexOf("internal_image") > -1 && xssAPI.encodeForHTMLAttr(imgSrc).indexOf("/internal_image/") > -1) {

    showimage = true;
}
if(showimage) {
%>
 Leave code as is provided by Adobe
<%
}
%>


Code Explanation:

Below code will remove the image if it is present under internal_image folder

if(imgSrc.indexOf("/internal_image/") > -1) {

    showimage = false;
}

In order to display the images for using in components, authors who are aware of folder path can search in asset finder, below code will make the image available if author is searching with folder name

if(request.getQueryString().indexOf("internal_image") > -1 && xssAPI.encodeForHTMLAttr(imgSrc).indexOf("/internal_image/") > -1) {

    showimage = true;
}

With above code we can create multiple internal_image folder (or any custom name) in any folder and add the images which should not be displayed on asset finder.

We can also create a configuration to list down the folders instead of hardcoding the value. 

Comments

Popular posts from this blog

AEM integration with Akamai Fast Purge API for Single/multiple urls

AEM Results count using query builder

AEM - Rollout a page programmatically and update references