10930 Posts in 2613 Topics by 1810 members
|Go to End||Next >|
7 April 2009 at 6:44am
If I were you, I would first extend the ImageGalleryPage class, and have it relate to another extended ImageGalleryItem class. Your ImageGalleryItem subclass could have a Thumbnail field.
class MyGallery extends ImageGalleryPage
protected $itemClass = "MyImageGalleryItem";
static $has_many = array (
'MyImageGalleryItems' => 'MyImageGalleryItem'
class MyImageGalleryItem extends ImageGalleryItem
static $has_one = array ('Thumbnail' => 'Image');
public function getCMSFields_forPopup()
$f = parent::getCMSFields_forPopup();
I'll make an update to the core to use the dynamic $itemClass property in the GalleryItems() control.
Then you just need to update your template to use the new thumbnail image.
7 April 2009 at 7:23am
Good evening UncleCheese,
I'm using SS 2.3.1 with your current SVN trunk and cannot select an album image from a sub subdirectory of the file store. The sub subdirectory icon has no "+" and is not expandable. Would you please fix that bug?
Thanks in advance!
P.S. Good job anyway!
7 April 2009 at 7:28am
Thanks, I think I understand how that will work. I can then do something similar to force the image_gallery to also load the uploaded image instead of the resampled one. I find that if I put a size in for the original it will make smaller images larger and so they won't look very good. I don't wan't to have to always upload images that are the size that is defined as the original size in the CMS.
I will like having a gallery that has my sized and cropped thumbnails and full size images.
Thanks again for your help. I am learning a lot about SS and OOP at the same time.
7 April 2009 at 7:29am
Sounds like a bug with the TreeDropdownField to me. Have you checked open.silverstripe.com?
7 April 2009 at 9:05am
Regarding the custom Thumbnail upload. I have implemented a solution based on your recommendation and now my gallery images have an extra image upload area which is good. When I upload a thumbnail image I can see the line get added to the database table where it should however I am missing something in my code as the popup does not display the thumbnail as the normal upload area does. Also I am not sure how to tell my template to get the uploaded thumbnail. I can see that in the template it uses $ThumbnailURL to get it but what would I use to get the new one?
Also is it possible to get the $ViewLink to display the path to the original image instead of the resized one?
7 April 2009 at 9:16am
You're going to need to modify the template a bit to get it to work. Create MyImageGalleryPage.ss, copy the template over from the image_gallery module, and customize it. To get the thumbnail all you should have to do in your GalleryItems control is $Thumbnail - assuming that's the name of the field on your ImageGalleryItem subclass.
As far as all the UI stuff, that's entirely up to you. But use the OO design pattern to overload the methods in ImageGalleryPage to customize the variables you need. I personally wouldn't bother with ViewLink if you're doing a custom template anyway. That stuff is just in there to support the UI plugins.
8 April 2009 at 5:36am Last edited: 8 April 2009 5:36am
I've found out that there's no problem with the TreeDropdownField. After importing images from an existing folder to a new album, all images from the original folder moved to a folder named "image-gallery/<album name>". The original folder still exists, but contains only a sub folder named "_resampled". The destination folder now contains the images and also a sub folder "_resampled".
Is this a bug or the right behaviour?
8 April 2009 at 5:51am
That's correct. All the resampled images go in the child folder _resampled. That's a Silverstripe convention.
|Go to Top||Next >|