Smart Image Resize
This is an open discussion with 6 replies, filed under XSLT.
Search
Nice tool. However I think you should turn things around:
<img> <xsl:attribute name="src"> <xsl:call-template name="smart-resize-image"> <xsl:with-param name="xml" select="entry-image"/> <xsl:with-param name="max-w" select="150"/> <xsl:with-param name="max-h" select="100"/> </xsl:call-template> </xsl:attribute> </img>
That way I am not restricted to adding alt
or class
alone but still can have all the crazy attributes I could possibly want.
@phoque yes, your addition can be one of many possible variations. Another option I thought about - automagical wrapping resized image with link to full sized image
Can this be used in the back end or is it more front end presentation? i.e the uploading of images in the admin area sometimes needs a restriction of max file upload and was wondering if this could be used to accomplish this?
This is purely for frontend, to limit image dimensions. It doesn’t touch file size. We’ve discussed elsewhere the possibility of a dedicated image upload field that deals with file sizes better.
Ok cool, thanks for the clarity :)
This has come in very handy. Thanks @andrrr.
I was getting an extra forward slash in the src attribute value, so I changed lines 27 and 30 from:
<xsl:value-of select="concat('/image/1/', $max-w,'/0/0/', $xml/@path, '/', $xml/filename)"/> </xsl:when> <xsl:when test="($b-side = 'h') and ($xml/meta/@height > $max-h)"> <xsl:value-of select="concat('/image/1/0/', $max-h,'/0/', $xml/@path, '/', $xml/filename)"/>
to:
<xsl:value-of select="concat('/image/1/', $max-w,'/0/0', $xml/@path, '/', $xml/filename)"/> </xsl:when> <xsl:when test="($b-side = 'h') and ($xml/meta/@height > $max-h)"> <xsl:value-of select="concat('/image/1/0/', $max-h,'/0', $xml/@path, '/', $xml/filename)"/>
Create an account or sign in to comment.
A new XSLT utility, “Smart Image Resize” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.