HippoCMS 7.9 - How to create image attributes

52 views
Skip to first unread message

Tyler Canton

unread,
Aug 20, 2015, 12:45:47 PM8/20/15
to Hippo Community

I'm currently working on a hippo component and I need the image link, alt, and title:

Component Method:


public HippoGalleryImageSetBean getImage() {
    return getLinkedBean(Constants.NS_FLD_IMAGE,
            HippoGalleryImageSetBean.class);
}


I would like to write my Component JSP like this below:


    <c:forEach var="item" items="${ document.links }"
               varStatus="loopStatus">
               <hst:link var="image"hippobean="${ item.image.original }" />

               <li><img
                    src="${ image }"
                    alt="${ image.alt }"
                    title="${ image.title} ">
                </li>
    </c:forEach>

Jeroen Reijn

unread,
Aug 20, 2015, 2:36:01 PM8/20/15
to hippo-c...@googlegroups.com
Hi Tyler,

Your code seems fine at a first glance. What isn't working?

Jeroen
--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.


--
Sent from Gmail Mobile

Jeroen Reijn

unread,
Aug 20, 2015, 2:40:21 PM8/20/15
to hippo-c...@googlegroups.com
Oops, sorry I see it now. The alt and title are defined on the imageset and not on the variants. Also ${image} in your case is the link generated for to an image and not the image object itself.

Try:

<c:forEach var="item" items="${ document.links }"
               varStatus="loopStatus">
               <hst:link var="imagelink"hippobean="${ item.image.original }" />

               <li><img
                    src="${ imagelink }"
                    alt="${ item.image.alt }"
                    title="${ item.image.title} ">
                </li>
    </c:forEach>
That should work.

Cheers,

Jeroen
--
Jeroen Reijn
Hippo

Amsterdam office - Oosteinde 11, 1017 WT Amsterdam
Boston office - 745 Atlantic Ave, Eight Floor, Boston MA 02111, United states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://blog.jeroenreijn.com | @jreijn | http://about.me/jeroenreijn

Tyler Canton

unread,
Aug 24, 2015, 9:03:00 PM8/24/15
to hippo-c...@googlegroups.com
Jeroen Reijn

     I'm a little confused, where is "${ item.image.alt }" coming from? How was that created without creating the logic for it. Or is that part of Hippo auto magic functionality coming from the HippoGalleryImageSetBean.class?

You received this message because you are subscribed to a topic in the Google Groups "Hippo Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hippo-community/UW4kxKLasbU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hippo-communi...@googlegroups.com.

Jeroen Reijn

unread,
Aug 25, 2015, 2:49:52 AM8/25/15
to hippo-c...@googlegroups.com
Hi Tyler,

well, I assumed you had defined those fields yourself. They are not part of the HippoGalleryImageSetBean. Looking at the template code I noticed that you tried to get those items from the wrong object. In general an image contained within an imageset does not offer any other information except, width and height, and most information is always stored in the imagesetbean (or child of) class.  

Cheers,

Jeroen

Tyler Canton

unread,
Aug 25, 2015, 11:17:41 AM8/25/15
to hippo-c...@googlegroups.com
So what's the best approach on creating those fields.I would like to create something in common so I can use across the board. 

Bert Leunis

unread,
Aug 28, 2015, 10:38:44 AM8/28/15
to Hippo Community
Hi Tyler,


On Tue, Aug 25, 2015 at 5:17 PM, Tyler Canton <t...@radleaf.com> wrote:
So what's the best approach on creating those fields.I would like to create something in common so I can use across the board. 
You should create your own imageset that extends the default HippoGalleryImageSet. Then you can add new fields easily for the alt and title. See this step [1] in the developer trail. There a new imageset is created (with some more variants than the default original and thumbnail). When you are done with the GalleryManager, you can find the document type in the Document Type editor [2], add the fields you like. Then with the BeanWriter tool, regenerate the bean for the imageset, rebuild and restart, and you are ready to go.

[1] http://www.onehippo.org/trails/developer-trail/configure-out-of-the-box-features/configure-image-variants.html
[2] http://www.onehippo.org/trails/developer-trail/develop-new-features/products-part-1-document-type.html
Reply all
Reply to author
Forward
0 new messages