Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Images dissapear after viewing the Files and Images tab

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3
Go to End
Author Topic: 3010 Views
  • dezmond
    Avatar
    Community Member
    17 Posts

    Re: Images dissapear after viewing the Files and Images tab Link to this post

    Ok, I started from scratch, re installedSS website, downloaded the latest DOM and the 'latest unstable build' of the Image Gallery. One thing I did differently this time after reading the installation instructions of Image gallery is that I installed both swfUpload and DOM modules BEFORE installing image gallery. Could this have made any difference? So far (fingers crossed) everything seems to working ok.

    Cheers

  • UncleCheese
    Avatar
    4085 Posts

    Re: Images dissapear after viewing the Files and Images tab Link to this post

    Did you happen to go through an upgrade to 2.4 on that last install? Strange things have happened to me when upgrading from 2.3 to 2.4, especially concerning the Assets section.

  • dezmond
    Avatar
    Community Member
    17 Posts

    Re: Images dissapear after viewing the Files and Images tab Link to this post

    No I was definitely on 2.4 before reinstalling.

  • charden
    Avatar
    Community Member
    7 Posts

    Re: Images dissapear after viewing the Files and Images tab Link to this post

    Hello everybody.

    We have been having similar issues with the image_gallery module as described here, even though we encountered it while trying to import previously uploaded files to an image gallery.

    Environment:
    SilverStripe: 2.4.2
    DataObjectManager: r511
    ImageGallery: r511
    Uploadify: r511

    Problem:
    When importing files already uploaded to SilverStripe to an ImageGalleryPage album, it will fail with a similar error message and stack trace as described by Chip Designs in the first post.

    Steps to reproduce:
    1. Create a new ImageGalleryPage, choose the default album.
    2. Click "Add images to $AlbumName".
    3. Select the "choose existing"-tab in the uploadify field.
    4. Select one or more existing images and click the "Import"-button.
    5. Press the "Continue"-button.
    6. Observe that the import fails with (roughly) the same error message as described in this thread.

    Likely cause:
    ImageGallery requires that all images which is handles is of the type ImageGalleryImage, however, when an existing image is imported it will be of type Image. When ImageGallery then tries to retrieve the Image through the ImageGalleryItem has_one-relation it will get an "empty" ImageGalleryImage-object since the ID points to an Image and not an ImageGalleryImage.

    Manually changing the ClassName of the given Image to ImageGalleryImage will solve the problem.

    Suggested solution:
    The ugly "make-it-work"-solution we are using right now simply adds some extra handling to ImageGalleryItem::onBeforeWrite() which will change the given Image to an ImageGalleryImage and write the changes. This will fix the import problem since it ensures that the given Image has the correct type.

    A better solution would probably be to get rid of ImageGallaryImage as a DataObject altogether and instead use a DataObjectDecorator for Image. Since all methods on ImageGalleryImage seems to use publicly available methods and features on Image, it should be implementable as a Decorator. If it works it should allow for ImageGallery to handle normal Images, which should remove the problem once and for all.

    Patch: http://gist.github.com/646912

    Edit: Added a link to the patch.
    Edit 2: Changed the description of the better solution a little.
    Edit 3: It seems like the first patch version was not working properly, it should be fixed now.

  • Sphere
    Avatar
    Community Member
    44 Posts

    Re: Images dissapear after viewing the Files and Images tab Link to this post

    I still get this error when I import an image into an album via "choose existing":

    [Notice] Trying to get property of non-object
    POST /admin/EditForm/field/GalleryItems/UploadifyForm?SecurityID=c8fbae9130cc2d82b31a123f901d179a11029e04&ctf[GalleryItems][start]=0&ctf[GalleryItems][per_page]=10&ctf[GalleryItems][showall]=0&ctf[GalleryItems][sort]=SortOrder&ctf[GalleryItems][sort_dir]=&ctf[GalleryItems][search]=&ctf[GalleryItems][filter]=AlbumID_2&ctf[GalleryItems][view]=grid&ctf[GalleryItems][imagesize]=100

    Line 140 in /var/www/vhosts/http-docs/image_gallery/code/ImageGalleryManager.php

    Source

    131    {
    132       $childData = parent::getChildDataObj();
    133       $childData->ImageGalleryPageID = $this->controllerID;
    134       return $childData;
    135    }
    136    
    137    public function getPreviewFieldFor($fileObject, $size = 150)
    138    {
    139       if($fileObject instanceof Image) {
    140          $URL = $fileObject->SetHeight($size)->URL;
    141          return new LiteralField("icon",
    142             "<div class='current-image'>
    143                <div id='preview-image'>
    144                   <img src='$URL' alt='' class='preview' />
    145                   <div class='ajax-loader'><img src='dataobject_manager/images/ajax-loader.gif' />". _t('ImageGalleryManager.ROTATING','Rotating')."...</div>
    146                </div>
    Trace

    ImageGalleryManager->getPreviewFieldFor(ImageGalleryImage)
    Line 529 of FileDataObjectManager.php
    FileDataObjectManager->EditUploadedForm()
    Line 453 of FileDataObjectManager.php
    FileDataObjectManager->saveUploadifyForm(Array,ImageGalleryManager_Popup,SS_HTTPRequest)
    Line 329 of Form.php
    Form->httpSubmission(SS_HTTPRequest)
    Line 143 of RequestHandler.php
    RequestHandler->handleRequest(SS_HTTPRequest)
    Line 161 of RequestHandler.php
    RequestHandler->handleRequest(SS_HTTPRequest)
    Line 161 of RequestHandler.php
    RequestHandler->handleRequest(SS_HTTPRequest)
    Line 161 of RequestHandler.php
    RequestHandler->handleRequest(SS_HTTPRequest)
    Line 147 of Controller.php
    Controller->handleRequest(SS_HTTPRequest)
    Line 282 of Director.php
    Director::handleRequest(SS_HTTPRequest,Session)
    Line 125 of Director.php
    Director::direct(/admin/EditForm/field/GalleryItems/UploadifyForm)
    Line 127 of main.php

    I noticed, the file is not being copied to the directory in which the $fileObject claims it should be. This is the actual error. It seems the saveImportForm is never actually triggered to copy the file to it's new position.

  • Mario...
    Avatar
    Community Member
    14 Posts

    Re: Images dissapear after viewing the Files and Images tab Link to this post

    I'm having the same problem as this: http://www.silverstripe.org/dataobjectmanager-module-forum/show/14115?start=8#post290785

    I 'm not using an ImageGallery though.

  • KM855
    Avatar
    Community Member
    1 Post

    Re: Images dissapear after viewing the Files and Images tab Link to this post

    I am experiencing the same problem.

    I have tried Silverstripe 2.4.5 and 2.4.0. At first I assumed it was the website I was working on, so I made a fresh installation of Silverstripe. I installed the Uploadify module, the Dataobject Manager module and the Image Gallery module. However, every time I upload the images via Files/Images and try to import them, I get this problem.

    In Silverstripe 2.4.5 I get no error message, but the images does not show a preview after importing when asked for captions. When I go to the website I can see the number of images, but when I open the album no images are displayed.

    In Silverstripe 2.4.0 I get the following error message: "[Notice] Trying to get property of non-object" which refers me to line 140 of ImageGalleryManager.php:

    137    public function getPreviewFieldFor($fileObject, $size = 150)
    138    {
    139       if($fileObject instanceof Image) {
    140          $URL = $fileObject->SetHeight($size)->URL;
    141          return new LiteralField("icon",
    142             "<div class='current-image'>
    143                <div id='preview-image'>
    144                   <img src='$URL' alt='' class='preview' />
    145                   <div class='ajax-loader'><img src='dataobject_manager/images/ajax-loader.gif' />". _t('ImageGalleryManager.ROTATING','Rotating')."...</div>
    146                </div>

    The funny thing is that the album's preview image can be imported without any problems.

    3010 Views
Page: 1 2 3
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.