Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Image Resize Question

Go to End

2 Posts   1844 Views


Community Member, 45 Posts

17 March 2009 at 7:43am

I have read the tutorial for creating a function to resize an image but i cannot seem to get it to work correctly. Here is my scenario: - this is the main Holder template that will contain the resized thumbnails - this is the detail page for each of the GalleryItems - the images that are resized on the Holder page are attached so the GalleryItemPage class

I have added the following code to the GalleryItemPage.php

class GalleryItemPage extends Page {
   static $db = array(
   static $has_one = array(
      'GalleryItemImage' => 'Image',
	  'GalleryItemThumb' => 'GalleryItemPage_Thumb150px'

on what page do i put the following function class?

class GalleryItemPage_Thumb150px extends Image {

   function generateThumb150px($gd) {
      return $gd->resizeRatio(150,150);

If I put in the GalleryItemPage.php file, it does not seem to be callable in the template - which is where i want the resized thumbnails to be generated.


Community Member, 45 Posts

17 March 2009 at 4:40pm

I found the issue. I did not pick up on the fact that I needed to update the ClassName for all the existing images I had already uploaded in File table. Once I updated all the thumb images with the class name of GalleryItemPage_Thumb150px, the resize code worked. This is key for making this change after you've already uploaded images under the Image classname.