Search

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.

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 &gt; $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 &gt; $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.

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