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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

reuse images from image gallery


Reply


6 Posts   722 Views

Avatar
janulka

Community Member, 80 Posts

6 September 2011 at 2:28am

I have uploaded several images to image gallery, and now I would like to reuse some uploaded images in simple "Image" field.

But when I choose the image I would like to display, they disappear from the gallery, and in SS there is only grey field left, unable to delete or do anything about it.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

7 September 2011 at 3:13am

Image gallery images are not standard images. They're actually a subclass of Image called "ImageGalleryImage." When you reuse the image on another page, it's setting the classname back to "Image" because that's what the relationship is on that page. That makes the image invisible to ImageGallery.

So you can either change the relationship on your other page to "ImageGalleryImage" instead of "Image" or just re-upload them on those pages.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
wmk

Community Member, 46 Posts

8 September 2011 at 1:16am

I never understood why subclass the image-class and not extend them with a decorator. It works, but you need the generate*() functions, too. Unfortunately they are not generated automatically (but afaik it's just a switch somewhere in sapphire):

class GalleryPic_Image extends DataObjectDecorator {

function generateSidebarThumbnail($gd) {
$gd->setQuality(85);
return $gd->paddedResize(65,65,'f3f3f3');
}

function SidebarThumbnail() {
return $this->owner->getFormattedImage('SidebarThumbnail');
}
}

This way i have a nice decorator and can reuse the images.

janulka: if you want to reuse them inside a html formfield, you can use shortcode handlers like shown for videos at [url=http://www.ssbits.com/tutorials/2010/2-4-using-short-codes-to-embed-a-youtube-video/]ssbits[/url]. This way i easily embed galleries and single images inside an article.

HTH, Werner

Avatar
UncleCheese

Forum Moderator, 4096 Posts

8 September 2011 at 3:46am

wmk is right.. It really should have been built as a decorator, but alas, ImageGallery was made long before I understood their purpose. :)

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
janulka

Community Member, 80 Posts

22 September 2011 at 7:07am

Edited: 22/09/2011 7:07am

thanks a lot

any chance I could get help with something else, not really related to SS, but to MySQL - I have uninstalled image-gallery module, I just need simple Image DOM for this one (many pages with just few images for each page), and now I am stuck with 300+ empty class names in 'File" table.

Can you plz help me with SQL query to change ClassName to "Image" for all records which do not have ClassName, at once?

Thank you!

Avatar
UncleCheese

Forum Moderator, 4096 Posts

22 September 2011 at 8:06am

UPDATE File SET ClassName = 'Image' WHERE ClassName IS NULL;