Rather take the first found image than the last one.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / NodeHttp.java
index bfa1f2f0aebb3235493ae7f2bbd41340e9a5232e..27083aeaba11812fd219ac60ab7e950ee3c01114 100644 (file)
@@ -142,10 +142,13 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants {
                                                .getProperty(JCR_LAST_MODIFIED).getDate() : null;
                                String url = CmsUtils.getCanonicalUrl(node, request);
                                String imgUrl = null;
-                               for (NodeIterator it = node.getNodes(); it.hasNext();) {
+                               loop: for (NodeIterator it = node.getNodes(); it.hasNext();) {
+                                       // Takes the first found cms:image
                                        Node child = it.nextNode();
-                                       if (child.isNodeType(CMS_IMAGE))
+                                       if (child.isNodeType(CMS_IMAGE)){
                                                imgUrl = CmsUtils.getDataUrl(child, request);
+                                               break loop;
+                                       }
                                }
                                StringBuilder buf = new StringBuilder();
                                buf.append("<html>");