21294 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1204 Views |
-
Extending Image

2 September 2009 at 12:35pm Last edited: 2 September 2009 12:38pm
Hey all, I've been going backwards and forwards through the wiki trying to find answers. Not sure if its me or Silver Stripe, so I ended up here.
Following this http://doc.silverstripe.com/doku.php?id=recipes:imageupload I've tired having this class in my dataobject, a gallery page, and finally thought it'd be best to have it self contained in its own file named "GalleryImage.php" with the following
class GalleryImage extends Image
{
function generateLarge($gd) {
$gd->setQuality(100);
return $gd->resizeRatio(350,500);
}function generateThumb($gd) {
$gd->setQuality(100);
return $gd->paddedResize(100,100);
}}
I always get call to member function on a non object. Am I naming the class incorectly? Some how the GD class isn't being accessed? Any light on the topic would be great. I'm using SS 2.3.3
P.S
I'm using uncle cheese's dataobject manager to allow for image caption and stuff, I'm associating the attachment with my GalleryImage like sostatic $has_one = array (
'Attachment' => 'GalleryImage',
'GalleryPage' => 'GalleryPage'
);
-
Re: Extending Image

2 September 2009 at 7:09pm
I have recently done something very similar to this and it worked just fine. How does your code in the template looks like?
-
Re: Extending Image

3 September 2009 at 8:55am
Thats good to hear that you've got it working, should hopefully mean I can to.
The code in the template is<img src="{$Attachment.Large.URL}" title="$Name" caption="$Caption"/>
I tried $Attachment.generateLarge.URL for the sake of it but get the same error.
-
Re: Extending Image

3 September 2009 at 9:15am
Pretty much all variations I try I end up with
Fatal error: Call to a member function setQuality() on a non-object in /home/lino/public_html/gallery/code/GalleryImage.php on line 5
with line 5 being $gd->setQuality(100); -
Re: Extending Image

3 September 2009 at 10:51am
Well I'm obviously missing something somewhere, I just installed the Image Gallery model and it works fine... I'll keep reading and trying.
-
Re: Extending Image

3 September 2009 at 11:14am
Well I've got it working. Not by extending the Image class but by writing functions in my DataObject. It might just be me but I found the wiki a little misleading.
Where is said croppedResize(width,height) it actually wanted CroppedImage(width,height). Do you have to write it Cropped{class name}(width, height); ??
Any way its bloody brilliant.
| 1204 Views | ||
|
Page:
1
|
Go to Top |


