We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42623
    • 3 Posts

    we use the gallery plugin version 1.6.2-pl with modx revo 2.2.14-pl.

    the gallery plugin creates cache folders with images inside like: 11.jpg, 33.jpg ...

    Is there a way to keep the original image filenames and not to rename the image names to numbers in the cache folders?

      • 53380
      • 1 Posts
      tenjou_utena Reply #2, 7 years ago
      I had that problem too and spend a lot of time trying to solve it. I hope my solution would be of any use.
      My version of MODX is MODX Revo 2.5.5., Gallery version - 1.7.0 (but I guess you can try it with earlier versions...)

      You should make some changes in files galalbum (core/components/gallery/model/gallery/galalbum.class.php) and, for Multi-Upload, in ajaxupload too (core/components/gallery/processors/mgr/item/ajaxupload.php).

      In galalbum.class.php:
      Find public function uploadItem. Change $shortName, it should be something like this:
      $shortName = $item->get('id').'__'.basename($name);

      So you will get files names like "123__SomeFileName.jpg", where the first number is ID of the file (I prefer not to erase it because you can have files with similar names in the same folder, and this will prevent conflicts), "SomeFileName.jpg" - original filename.

      This works only for single file upload (and breaks Multi-Upload).

      And now Multi-Upload. in galalbum.class.php change this:
      $target = fopen($this->getPath(false).$shortName, "w");

      to this:
      $target = fopen($this->getPath(true).$shortName, "w");

      And in ajaxupload.php:
      $filename = $item->get('id').'.'.$extension;

      change to this:
      $filename = $filenm;

      And one more thing. I need to mention that I use some additional methods to cache thumbnails and store them, so I don't know if my solution for filenames would work smoothly without this caching... I took code for caching here: https://www.createit.ru/blog/modx/2012/caching-preview-images-in-gallery Sorry, this article is not in english( I hope online translation would work fine.