We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22427
    • 793 Posts
    Hi all,

    its for a long time I always was getting angry trying to implement pictures by gallery synch which have been copied to the gallery directory before (already adapted in size). It often came to an endless loop, stopped only by exceeding max_execution_time.

    The site runs under Vista using MODx 1.0.0 and MaxiGallery Version 0.5.2, up to now only locally (xampp).

    During synchronisation obviously MaxiGallery takes already rendered pictures anew as originals to process; of an original named picture.jpg f.i. I got the files
    picture.jpg
    1picture.jpg
    11picture.jpg
    111picture.jpg
    1111picture.jpg
    etc.
    (and the relative thumbs of course).

    The problem arises only by the fact that the original files to process and the resulting files are located in the same directory (that is never a good idea...). And the solution is in changing this.

    At first, for the (so far empty) gallery directory (e.g. assets/galleries/55) I created a subdirectory orig and copied the original files into it (that is into assets/galleries/55/orig).

    Now in the file maxigallery.php (in the directory assets/snippets/maxigallery) there is the need of two changes in the section about gallery_synch (from line 462 on):

    Line 479 instead of
    $dh = opendir($mg->path_to_gal);

    has to become
    $dh = opendir($mg->path_to_gal."orig/");

    And line 492,
    if(rename($mg->path_to_gal.$name, $mg->path_to_gal.$newname)){

    must be changed to
    if(rename($mg->path_to_gal."orig/".$name, $mg->path_to_gal.$newname)){


    This solved the problem.

    After the synch process the directory orig is empty. But better keep it alive because you need it for adding new pictures to the gallery: Copy the original files into it, do the synch and you’re done.

    The changes in the file maxigallery.php of course affect already existing galleries too - at least if you want to add new pictures to an old gallery. You just create a subdirectory orig of its gallery directory and copy the new originals into it. Resynch, done.

    For the first time I am able to assure my manager users that it’s possible to fill galleries by FTP upload without being forced to upload picture by picture via the form...

    I only hope not to have missed some unwanted side effects.

    Kind regards to all of you
    ottogal