How to Create Square Thumbnails in K2 for Joomla! 1.5

K2 is definitely one of my favorite Joomla! components. It does everything so well that I rarely need to make edits to anything other than template files. The one exception is creating square thumbnails. Most of my customers incapable of creating square thumbnails, so we need the system to be as user friendly as possible.

This is a quick tutorial on creating square cropped thumbnails with K2. We are going to make the small images square, but you could apply this code to any image size.

*This modification will be lost with each upgrade to k2, so be sure to keep a backup of this code handy.

Open: administrator\components\com_k2\models\item.php

Search for “//Small image”

We are going to replace the entire block of code responsible for the image resizing.

You can now upload your images to your items. All small images (images set as small) will now be cropped square. The width and height will match the default size for the small image size, or the custom size set by you in the category parameters.

Tarik (@tarik916) is a web developer and owner of ACS Digital Media, a Sacramento based web development agency specializing in open source CMS systems. If you are looking for support for your current or upcoming projects, visit www.acs-digital.com.

This is possible, but I have not had to do it yet since categories are added less frequently than content items. Most people just upload a square image. If you want to do it through the code, you can edit administrator/components/com_k2/models/category.php.