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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

reuse images from image gallery


Go to End


6 Posts   1048 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, 4102 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, 87 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 ssbits. This way i easily embed galleries and single images inside an article.

HTH, Werner

Avatar
UncleCheese

Forum Moderator, 4102 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, 4102 Posts

22 September 2011 at 8:06am

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