I need to add rel="lightbox"
to the anchor tag when you select a target image using either Image or TextImage component. The anchor tag is automatically generated by CQ, but I am unable to find where this happens, or more importantly, if there is a method I can call to add this string.
I am looking over the Adobe documentation for the built-in Image component (http://dev.day.com/docs/en/cq/5-3/javadoc/com/day/cq/wcm/foundation/Image.html), which I cloned and modified slightly for separate Lightbox use.
Image object has protected Map<String,String> getImageTagAttributes()
, and I hope there is some equivalent object for anchors in a class that I'm not aware of.
Here is our current Image component that I used for reference.
<%@ page import="commons.Doctype,
wcm.api.components.DropTarget,
wcm.foundation.Image" %><%
%><%@include file="/apps/site/global.jsp"%><%
String alignment = properties.get("alignment", "");
Image image = new Image(resource);
//drop target css class = dd prefix + name of the drop target in the edit config
image.addCssClass(DropTarget.CSS_CLASS_PREFIX + "image");
if (!alignment.isEmpty() && !alignment.equals("center"))
image.addCssClass(alignment);
image.loadStyleData(currentStyle);
image.setSelector(".img"); // use image script
image.setDoctype(Doctype.fromRequest(request));
// add design information if not default (i.e. for reference paras)
if (!currentDesign.equals(resourceDesign)) {
image.setSuffix(currentDesign.getId());
}
if (alignment.equals("center")) {
%><div class="center"><%
}
%><% image.draw(out); %><%
%><cq:text property="jcr:description" placeholder="" tagName="small"/>
<% if (alignment.equals("center")) {%>
</div>
<% } %>
Right now I'm using jQuery to do the job, but I don't want to rely on scripting if possible.