1 Reply Latest reply on Sep 13, 2012 8:30 PM by Yogesh Upadhyay

    how do i get the width and height of an image resource in the rendering jsp?


      so i am customizing the foundation image component, and i need to be able to get the width and height of the image(if it is cropped i need the cropped dimensions) and if not cropped i need the default dimensions for that image within that rendering jsp before embedding the image in html.


      what i have below is kind of a mockup



          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");


          image.setSelector(".img"); // use image script


          // add design information if not default (i.e. for reference paras)

          if (!currentDesign.equals(resourceDesign)) {



          String divId = "cq-image-jsp-" + resource.getPath();


          String srcURL = image.getFileReference();


          int imgWidth;

          int imgHeight;









              //need to know dimensions before this point so i can explicitly specify them in the img tag

              <a href="#" id="a<%= srcURL %>"><img id="item<%= srcURL %>" class="content" src="<%= image.getSrc() %>" title="<%= properties.get("jcr:title", "") %>" height="<%= imgHeight %>" width="<%= imgWidth %>"/></a>