I have tried to use something like this instead of the imgHeight variable:
<xsl:variable name="tempImgHeight" select="number(umbracoHeight) div $scale"/> <xsl:variable name="imgHeight"> <xsl:choose> <xsl:when test="$tempImgHeight < number('#.5')"> <xsl:value-of select="floor(number(umbracoHeight) div $scale)" disable-output-escaping="yes"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ceiling(number(umbracoHeight) div $scale)" disable-output-escaping="yes"/> </xsl:otherwise> </xsl:choose> </xsl:variable>
But it doesn't seem to be quite correct, as I either get the height of images only with floor or ceiling method. In the example above I get either: 274px and 366px or 275px and 367px, but the sizes of the images I have tested on should be 274px and 267px in height when the width is set to 250px.
Calculate width and height of image
Hi..
I would like to set the width and height of an image, where I have a fixed width of the image:
How can I check if the decimals lower than xx.5 and then use floor, or equal or greater than xx.5 and then use ceiling?
so if the height is calculated to 274.1779497098646 it should be set to 274 and if the height is calculated to 366.75126903553297 it should be 367.
Bjarne
I have tried to use something like this instead of the imgHeight variable:
But it doesn't seem to be quite correct, as I either get the height of images only with floor or ceiling method.
In the example above I get either: 274px and 366px or 275px and 367px, but the sizes of the images I have tested on should be 274px and 267px in height when the width is set to 250px.
Bjarne
Okay.. I decided to use the round method instead and is probably better as it automatically rounds the number to the nearest integer..
Bjarne
is working on a reply...