Search

Hello,

I need to add the image dimensions of an JIT manipulated image to my markup. Is there a way to get the size of the image in xsl?

Thanks – Moritz

I don't believe there is, as you'd have to send a second request to the server to get the dimensions if it was in a JIT recipe. Is there are particular reason you need the width? It might be possible to get around it if it's for styling/CSS reasons...

Hello Henry, thanks for your reply,

it is for styling reasons, indeed. I am using isotope for my layout and isotope needs image dimensions to work properly (in some browsers). Would it be an idea to first add image dimensions by javascript and then apply the isotope layout script?

If possible, I had preffered to att the dimensions to the markup already. I am using a JIT recipe but I could give it up and add the JIT command directly into my xsl. However, only one dimension is fix (width) while the other then depends on the image being processed.

There is a recipes datasource included with the JIT extension. You can use this with the dimensions from the original image coming from the upload field XML output to calculate the output size.

You could also use the width and height attribute from the meta node in your xml to calculate the resized dimensions…
Example: img src="{$root}/image/recipe/{images/filename}" width="400" height="{round(images/meta/@height * (400 div images/meta/@width))}"/

Great, it works. Thank you both! I have used the recipe datasource.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details