7 users online. Create an account or sign in to join them.Users
Getting JIT generated unknown dimension
This is an open discussion with 4 replies, filed under Extensions.
Search
You can’t I’m afraid. Why not leave the width attribute off completely?
Ay, the layout will be quite jQuery-heavy, and javascript needs the dimensions before the image(s) is/are loaded. Waiting for all images to load before layouting is not an option.
I’m familiar with PHP and getimagesize. I could do the calculations myself, I’m just not sure where and how to put the code…
thanks, J
When you get your image from a upload-field it provides the original width- and height. Using some math you can calculate the corresponding height:
XML:
<image size="22 KB" path="/uploads/portfolio/images" type="image/jpeg">
<filename>my_image.jpg</filename>
<meta creation="2010-09-28T12:26:18+02:00" width="626" height="202" />
</image>
XSLT:
<!-- To calculate the correct height: -->
<img src="/image/2/100/0/5{image/@path}/{image/filename}" width="100">
<xsl:attribute name="height">
<xsl:value-of select="round(image/meta/@height * (100 div image/meta/@width))" />
</xsl:attribute>
</img>
<!-- To calculate the correct width: -->
<img src="/image/2/0/100/5{image/@path}/{image/filename}" height="100">
<xsl:attribute name="width">
<xsl:value-of select="round(image/meta/@width * (100 div image/meta/@height))" />
</xsl:attribute>
</img>
Never underestimate the power of math! ;-)
Ha! One day, I shall be a xslt ninja as well
many thanks! J
Create an account or sign in to comment.
Hello, If I generate an image using 0, the width of the thumbnail is calculated for me. Like:
But, how do I get the value of that width? so i can put it into the html”
thanks!