In order to use the lightbox, I need a link to the image as generated by <p:graphicImage>
.
Ultimately, the HTML should look like this:
<a href="image.jpg" data-lightbox="bilder">
<img src="image.jpg" />
</a>
This is my JSF attempt so far:
<h:outputLink data-lightbox="bilder" value="???">
<p:graphicImage value="#{imageStreamer.image}">
<f:param name="imageId" value="#{gameReader.game.cover.id}"/>
</p:graphicImage>
</h:outputLink>
How do I get the concrete URL of <p:graphicImage>
returning StreamedContent
so that I can use it in my link?
Have suggested a solution to this question here.
Long story short, you can use the
getImageSrc
method of theGraphicImageRenderer
in order to get the image URI.First step is extending the
GraphicImageRenderer
to publish the protectedgetImageSrc
method:The we need a method in managed bean that enables us use the
getPublicImageSrc
method:Finally we bind the
p:graphicImage
component to an arbitrary variable and invokemyBean.getImgUri
to get the Uri for any purpose: