ImpressCMS can resize images automatically in the template

ImpressCMS (1.2 Upwards) can resize images automatically if you tell it what images and where to put them. You just need to insert a Smarty tag in your design where you want the resized image to be.

UPDATED: You can download an updated version of this plugin (1.11, december 22, 2010), including some bugfixes.

Note: You can find updated info on the ImpressCMS Wiki.

resized_image resizes an image to the specified size and returns a formatted HTML tag pointing to the resized copy.

Example:

<{resized_image file="full_path_to_the_file" height=xxx width=xxx fit="foo"}>

It automatically checks if the original image has changed, and rebuilds the resized copy when needed. It stores those resized copies in the 'cache' folder.

Parameters:

-file : file (and path) of image (required)

-height : image height (optional, default actual height)

-width : image width (optional, default actual width)

- return : (optional) 'url' returns the URL of the resized image. 'img' returns a full built IMG tag. Defaults to 'img'.

-basedir : base directory for absolute paths, default is environment variable DOCUMENT_ROOT

-path_prefix : prefix for path output (optional, default empty)

-fit : The way the image is resized. Possible values:

  • inside (the image will fit inside the new dimensions while maintaining the aspect ratio)
  • fill (the image will completely fit inside the new dimensions)
  • outside (the image will be resized to completely fill the specified rectangle, while still maintaining aspect ratio)

Requirements (lack of):

You don't depend on a module's ability to resize images anymore, and you don't need to have GD2 or ImageMagik installed in your host. It uses internal iCMS core components to do the job.

Troubleshooting:

The plugin reports any problem found whenever possible. If you have problems, activate debug console and reload the page. There should be an error message referring the problem.

Practical uses:

You can add thumbs and Suppose you have a photo gallery and you decide to change the thumbnail and medium size. You just have to change the tag code and you're done.

AttachmentSize
function.resized_image.1-11.zip2.79 KB

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <i> <b> <strong> <cite> <pre> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <img> <h2> <h3> <blockquote>
  • Lines and paragraphs break automatically.

More information about formatting options