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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Image Gallery: Creating too many folders...

Go to End

10 Posts   4739 Views


Community Member, 24 Posts

22 July 2011 at 10:08pm

I posted about a related issue 11 days ago, but noone seemed to have experienced the same problems as me.
However, after reading this post about the many folders created, I am now pretty much convinced that my issues are the same as what you are describing in this post,

I have about 10 galleries (10 image gallery pages with a separate gallery for each) on a site.

Here is my test workflow which describes the problem:
If I right click and "duplicate just this page" on one of the imagegallery pages, lets say the page is named gallery1 (same with the album).
I then rename the new page to gallery2, hit save and publish, go to the albums tab, create a new album called gallery2, hit save, go over to the photos tab and start uploading. Then hit save and publish etc.
(sorry about the grammar, its 4am)

Now this is where the weirdness starts:
- If I now go back to gallery1, go to its photos tab and start uploading more photos to this first gallery - I notice that the directory for where the photos are uploaded to for this gallery has now changed to "assets/image-gallery/gallery2/gallery1/imagename.jpg"
I am not kidding. - I am monitoring the server at the same time.
I then hit "save and publish" and,,, the folder now changes its name to /image-gallery/gallery1/gallery1/imagename.jpg
(which now also contains the folder ../gallery1/gallery2/ used for the second image gallery page)

- To complete the test, I now go back to the gallery2 page, upload more images to this page, and notice that the new photo gets uploaded to /image-gallery/gallery1/gallery2/imagename.jpg.
But as soon as I hit "save and publish" the folder name on the server changes to /image-gallery/gallery2/gallery2/imagename.jpg

somehow both pages are tied together, folder names changing according to the last gallery edited. and in the end, as is what happened in my old post, you get an error when the cms tries to move files (rename) from one folder to another and things get messy.

would be interesting to hear if this is just my isolated observation, maybe due to a misconfigured server, mis-install, corrupt files, etc. or if other people are able to replicate.
I guess that most people only use one image gallery per website?

and btw, thanks for a great image gallery and all the hard work put in to this and the DOM, Uploadify.


Community Member, 135 Posts

2 August 2011 at 1:31pm

I have already posted about this in aonther thread but here it is again and some more comments:

Dear Uncle Cheese..

I too was afflicted by the duplicate folder bug and eventually traced it to this code in ImageGalleryPage.php :

function checkFolder() {
if( ! $this->RootFolderID ) {
$galleries = Folder::findOrMake('image-gallery');
$galleries->Title = 'Image Gallery';
$folder = Folder::findOrMake('image-gallery/' . $this->URLSegment);
$folder->Title = $this->Title;

$this->RootFolderID = $folder->ID;

FormResponse::add( "\$( 'Form_EditForm' ).getPageFromServer( $this->ID );" );
else {


The $this->write() seems very often to not write the actual root folder under image-gallery/ but some other spurious folder number. I have not found the cause of that yet but it does not seem to matter what the number is although if it is wrong it will create an apparent "Gallery" (or whatever your page name is) folder in the root of the assets list in the Files & Images tab. It does not create a filesystem folder. If one manually sets the entry in the ImageGalleryPage table to the correct folder ID then all becomes well.
So the first question is what is the RootFolderID for? Other than the creation of spurious virtual directories if it is wrong it appears to have no other effect. I will investigate.

The second and MUCH bigger question is that I believe the entire gallery works backwards. We spend ages building up a filesystem and database of images which is easily damaged and not rebuilt using /dev/tasks/FilesystemSyncTask, whereas actually executing that function builds the ImageGallery image database in the Files & Images Folder anyway. So we wind up during development and testing with galleries we can see in Files & Images but can't use!

So why not change the ImageGallery so that when creating a new gallery we just point it to a Files & Images folder we have already created (and perhaps enabling us to add some more). Use the captions already provided. This stops reinventing the wheel so to speak and means the whole thing is far more bulletproof and self repairing than it is now where there is a separate and fairly fragile database. Indeed you could ftp images up there do a /dev/task and whammy the gallery would have them. Even the upgrade path for existing galleries would be simple.

I shall be working on this when I have time and post it.

Go to Top