8 Replies Latest reply on Oct 15, 2015 7:26 PM by Ojjis

    Get information about html5smartimage

    Jakolcz Level 1

      I'm creating component with html5smartimage and few fields for aditional info. How can I get information(especially URL) about the image? I know how to access pathfield/textfield info but I don't know how to get html5smartimage info.
      This is my html5smartimage

      Thanks for any help.

      • 0. Re: Get information about html5smartimage
        Ojjis Level 4
        Ok. Here is how you can get it, This is purely based on the standard image component and it's jsp from CQ in which you use the settings:


        <% Image image = new Image(resource); image.addCssClass(DropTarget.CSS_CLASS_PREFIX + "image"); image.loadStyleData(currentStyle); image.setSelector(".img"); // use image script image.setDoctype(Doctype.fromRequest(request)); if (!currentDesign.equals(resourceDesign)) { image.setSuffix(currentDesign.getId()); } //Then you can get the path of the actual image like this //results in eg. /content/dam/mystuff/Images/mypicture.jpg String imagePath = (String) image.getFileReference(); %>

        The image.getFileReference method is inherited from com.day.cq.commons.DownloadResource which has loads of other methods as well if you want to get more info about the image/file. Just browse through the documentation

        Good luck :)