Tuesday, 28 February 2012

Enhancements to Content Presenter Image Gallery

Original code and instrucions:
(credit John Brunswick and Kyle Hatlestad)

The following is an enhancement of the image gallery template.
Prereqs: 
-Requires static renditions to be accessible, need config.cfg renditions for preview and thumbnail. You can just google that
-Requires dispersion to be turned off, kyle has an article on this

You'd replace the iterator code in the template with the below:
<af:iterator rows="0" var="node" varStatus="iterator" value="#{nodes}" id="it0">       
 <af:outputText escape="false" value="&lt;a class=&quot;grouped_elements&quot; title=&quot;#{node.propertyMap['xComments'] != 'xComments: ' ? node.propertyMap['xComments'].asTextHtml : node.propertyMap['dDocTitle'].value.stringValue}&quot; rel=&quot;group&quot; href=&quot;/cs/groups/#{fn:toLowerCase(node.propertyMap['dSecurityGroup'].value.stringValue)}/documents/#{fn:toLowerCase(node.propertyMap['dDocType'].value.stringValue)}/~extract/#{node.propertyMap['dDocName'].value.stringValue}~1~staticrendition/preview.gif&quot;>"/>       
 <af:image source="//cs/groups/#{fn:toLowerCase(node.propertyMap['dSecurityGroup'].value.stringValue)}/documents/#{fn:toLowerCase(node.propertyMap['dDocType'].value.stringValue)}/~extract/#{node.propertyMap['dDocName'].value.stringValue}~1~staticrendition/thumbnail.png" styleClass="gallery"/>         
<af:outputText escape="false" value="&lt;/a>"/>     
</af:iterator>

This allows any security group, or document type on checkin, also uses relative urls.
It standardizes the thumbnail and enlarged size to the standard IBR renditions.

The only remaining issue with this code, is if you put the image inside a space rather than any contribution folder, it requires the auth and account value to be dynamically set in the folder path. I haven't worked out how to do string manipulation to make this dynamic. EL APIs are still a mystery to me, anyone with a good link? As a result this code only supports sourcing the images from any contribution folders.
Also the folder must only contain images. If your images are in folders with mixed content or sub folders, you need to use a list rather than point presenter to a folder.