当您使用Image或TextImage组件选择目标图像时,我需要将rel="lightbox"
添加到锚标记。锚标签是由CQ自动生成的,但是我无法找到这种情况发生的地方,或者更重要的是,如果有一种方法我可以调用来添加这个字符串。
我正在查看内置图像组件(http://dev.day.com/docs/en/cq/5-3/javadoc/com/day/cq/wcm/foundation/Image.html)的Adobe文档,我对其进行了克隆和修改,以便单独使用Lightbox。
图像对象有protected Map<String,String> getImageTagAttributes()
,我希望在我不知道的类中有一些等效的锚点对象。
这是我用于参考的当前图像组件。
<%@ 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>
<% } %>
现在我正在使用jQuery来完成这项工作,但如果可能,我不想依赖脚本。
答案 0 :(得分:1)
答案 1 :(得分:0)
你可以看看Sling Rewriters做这项工作:http://sling.apache.org/site/rewriting-the-output-through-pipelines.html基本上你可以解析你的回复并动态修改它。