which also work fine.. but I would like to change the value of imgHeight when its value is greater than 170, then it should set the value a height to 170.. and the calculate the imgWidth from a height of 170.
Something like:
<xsl:variable name="imgHeight" select="'170'"/> <xsl:variable name="scale" select="number(./productImage/DAMP/mediaItem[1]/Image/umbracoHeight) div $imgHeight"/> <xsl:variable name="imgWidth" select="round(number(./productImage/DAMP/mediaItem[1]/Image/umbracoWidth) div $scale)"/>
But I'm not sure how to use it with the first examle.. so it just use the values from the first snippet when imgHeight is lower than or equal 170 otherwise it sets imgHeight to 170 and then calculate a different imgWidth that always will be lower than 170.
you don't need to calculate the width of the image if height is to be set to 170, Check the documentation, all you need to do is calculate the height (170 or less) and do not specify width as a param, image will be resized to fit the specified height.
I use the variables to specify height and width attributes, so the browser knows the proportions before the image is loaded, which I also have done in the product list here: http://sub.ak-security.dk/da/shop/brandmateriel.aspx
But on the page the image of the fire blanket has a small width and so the height will not fit in when I use 170px as width of the image. So in case that the height is greater than 170px I want to decrease the width to what fits proportional to the height. Then the image would have the proportions of 78 x 170 px (width / height).
So that it's in these cases, where height is greater than width, I want to set the height to 170px and the width will be variable.
Change value of variable when value is greater than...
Hi..
I use these variables to set the height and width attributes of the image:
which also work fine.. but I would like to change the value of imgHeight when its value is greater than 170, then it should set the value a height to 170.. and the calculate the imgWidth from a height of 170.
Something like:
But I'm not sure how to use it with the first examle.. so it just use the values from the first snippet when imgHeight is lower than or equal 170 otherwise it sets imgHeight to 170 and then calculate a different imgWidth that always will be lower than 170.
Bjarne
Hi Bjarne,
you don't need to calculate the width of the image if height is to be set to 170, Check the documentation, all you need to do is calculate the height (170 or less) and do not specify width as a param, image will be resized to fit the specified height.
Cheers,
/Dirk
Hi Dirk
I use the variables to specify height and width attributes, so the browser knows the proportions before the image is loaded, which I also have done in the product list here: http://sub.ak-security.dk/da/shop/brandmateriel.aspx
But on the page the image of the fire blanket has a small width and so the height will not fit in when I use 170px as width of the image.
So in case that the height is greater than 170px I want to decrease the width to what fits proportional to the height. Then the image would have the proportions of 78 x 170 px (width / height).
So that it's in these cases, where height is greater than width, I want to set the height to 170px and the width will be variable.
Bjarne
is working on a reply...