Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » reuse images from image gallery

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 666 Views
  • janulka
    Avatar
    Community Member
    80 Posts

    reuse images from image gallery Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: reuse images from image gallery Link to this post

    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

  • wmk
    Avatar
    Community Member
    45 Posts

    Re: reuse images from image gallery Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: reuse images from image gallery Link to this post

    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

  • janulka
    Avatar
    Community Member
    80 Posts

    Re: reuse images from image gallery Link to this post

    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!

  • UncleCheese
    Avatar
    4085 Posts

    Re: reuse images from image gallery Link to this post

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

    666 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.