We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28215
    • 4,149 Posts
    The default galAlbumRowWithCoverTpl:
    <li>
        <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]">
            <img src="[[+image]]" alt="[[+name]]" />
            <span>[[+name]]</span>
        </a>
    </li>


    If you want to override it, create a chunk with a different name, and set that to &rowTpl.
      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • 5340
      • 1,624 Posts
      You beat me to it

      Mine is:

      <div class="albumPreview">
                  <h3>[[+name]]</h3>
                  <div class="thumb">
                    <img src="[[+image]]" alt="[[+name]]"/>
                  </div>
                  <div class="desc">
                      <p>[[+description]]</p>
                      <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]" class="view">View gallery</a>
                  </div>
              </div>



      +

      [[!GalleryAlbums? &limit=`0` &albumCoverSort=`rank` &prominentOnly=`0` &rowTpl=`GalAlbumRowTpl`]]
        • 5340
        • 1,624 Posts
        Just curios about the steps I need to take to get/generate the following information for the albums

        Last changed on Oct 27, 2010. This album contains 42 items.
        This album has been viewed 363 times since Oct 27, 2010.


        I will need something similar for each photo.

        Thanks
          • 36447
          • 98 Posts
          Thanks cipa and shaun--I much prefer this solution to hacking the GalleryAlbums snippet, but thanks also to @greenvisions for sharing a solution that also works.
            • 36461
            • 102 Posts
            Thank you all now I’m one step closer to what I wanted all this time smiley

            @Cipa
            I tried using your method, but I can’t get gallery thumbs displayed. I tried using greenvisions method and tagged cover image with "Cover", that worked. How should I tag cover image using your output method ?


            I still have 1 mayor issue. When I press on gallery thumbnail or "view gallery" nothing happens, I can’t view any gallery images. What am I doing wrong ?
              • 5340
              • 1,624 Posts
              A tutorial is coming in a few minutes. Hopefully it will help you
                • 5340
                • 1,624 Posts
                Tutorial here. Please provide feedback if something does not work.

                Thanks
                  • 36461
                  • 102 Posts
                  wow,

                  Thanks for your tutorial cipa !!

                  I’m still having some problems though sad

                  Album thumbnail image isn’t displayed, do you need to name or tag one of album images specifically ?
                  Wehn clicking "view gallery" still nothing happens.

                  I was inspecting your tutorials demo code output for the gallery:

                              <div class="albumPreview">
                    <h3><a href="demo/modx-revolution-photo-gallery.html?galAlbum=1">Demo Album 1</a></h3>
                              <div class="thumb">
                                <a href="demo/modx-revolution-photo-gallery.html?galAlbum=1"><img src="http://cipalabs.com/assets/components/gallery/connector.php?action=web/phpthumb&w=195&h=140&zc=1&far=1&q=90&src=http%3A%2F%2Fcipalabs.com%2Fassets%2Fcomponents%2Fgallery%2Ffiles%2F2011%2F02%2Fimg_4380.jpg" alt="Demo Album 1"/></a>
                              </div>
                              <div class="desc">
                                  <p>Demo Album 1 - Description</p>
                  
                                  <a href="demo/modx-revolution-photo-gallery.html?galAlbum=1" class="view">View gallery</a>
                              </div>
                          </div>
                  


                  And compared it to my output:

                  <div class="albumPreview">
                      <h3><a href="majas-lapas/template-majas-lapa.html?galAlbum=2">Antikvariāts</a></h3>
                      <div class="thumb">
                          <a href="majas-lapas/template-majas-lapa.html?galAlbum=2"><img src="" alt="Antikvariāts"/></a>
                      </div>
                      <div class="desc">
                          <p></p>
                  
                          <a href="majas-lapas/template-majas-lapa.html?galAlbum=2" class="view">View gallery</a>
                      </div>
                  </div>
                  <div class="albumPreview">
                      <h3><a href="majas-lapas/template-majas-lapa.html?galAlbum=1">Amatnieku viekali</a></h3>
                      <div class="thumb">
                          <a href="majas-lapas/template-majas-lapa.html?galAlbum=1"><img src="" alt="Amatnieku viekali"/></a>
                      </div>
                      <div class="desc">
                  
                          <p>Amatnieku viekali</p>
                          <a href="majas-lapas/template-majas-lapa.html?galAlbum=1" class="view">View gallery</a>
                      </div>
                  </div>
                  


                  It seems that for some img src is blank. I can’t figure out why though. I have 1 image in album "Antikvariāts" and 3 images in album "Amatnieku veikali" I have checked active and prominent in both albums.

                  I have included small screenshot of how my output looks like
                    • 5340
                    • 1,624 Posts
                    Please post your snippet calls and chunks.
                    Thanks
                      • 36461
                      • 102 Posts
                      Ok,

                      Chunks:

                      galAlbumRowTpl
                      <div class="albumPreview">
                          <h3><a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]">[[+name]]</a></h3>
                          <div class="thumb">
                              <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]"><img src="[[+image]]" alt="[[+name]]"/></a>
                          </div>
                          <div class="desc">
                              <p>[[+description]]</p>
                              <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]" class="view">View gallery</a>
                          </div>
                      </div>


                      galAlbumTpl
                      <h1>[[+album_name]]</h1>
                      <p>[[+album_description]]</p>
                      [[+thumbnails]]


                      galItemThumb
                      <div class="[[+cls]]">
                          <a href="[[+linkToImage:if=`[[+linkToImage]]`:is=`1`:then=`[[+image_absolute]]`:else=`[[~[[*id]]?
                                  &[[+imageGetParam]]=`[[+id]]`
                                  &[[+albumRequestVar]]=`[[+album]]`
                                  &[[+tagRequestVar]]=`[[+tag]]` ]]`]]">
                      
                              <img class="[[+imgCls]]" src="[[+thumbnail]]" alt="[[+name]]" />
                          </a>
                      </div>


                      Snippets

                      Gallery
                      <?php
                      /**
                       * Gallery
                       *
                       * Copyright 2010 by Shaun McCormick <[email protected]>
                       *
                       * Gallery is free software; you can redistribute it and/or modify it under the
                       * terms of the GNU General Public License as published by the Free Software
                       * Foundation; either version 2 of the License, or (at your option) any later
                       * version.
                       *
                       * Gallery is distributed in the hope that it will be useful, but WITHOUT ANY
                       * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
                       * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
                       *
                       * You should have received a copy of the GNU General Public License along with
                       * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple
                       * Place, Suite 330, Boston, MA 02111-1307 USA
                       *
                       * @package gallery
                       */
                      /**
                       * The main Gallery snippet.
                       *
                       * @package gallery
                       */
                      $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
                      if (!($gallery instanceof Gallery)) return '';
                      
                      /* setup default properties */
                      $album = $modx->getOption('album',$scriptProperties,false);
                      $plugin = $modx->getOption('plugin',$scriptProperties,'');
                      $tag = $modx->getOption('tag',$scriptProperties,'');
                      $limit = $modx->getOption('limit',$scriptProperties,0);
                      $start = $modx->getOption('start',$scriptProperties,0);
                      $sort = $modx->getOption('sort',$scriptProperties,'rank');
                      $sortAlias = $modx->getOption('sortAlias',$scriptProperties,'galItem');
                      if ($sort == 'rank') $sortAlias = 'AlbumItems';
                      $dir = $modx->getOption('dir',$scriptProperties,'ASC');
                      $showInactive = $modx->getOption('showInactive',$scriptProperties,false);
                      $linkToImage = $modx->getOption('linkToImage',$scriptProperties,false);
                      $imageGetParam = $modx->getOption('imageGetParam',$scriptProperties,'galItem');
                      $albumRequestVar = $modx->getOption('albumRequestVar',$scriptProperties,'galAlbum');
                      $tagRequestVar = $modx->getOption('tagRequestVar',$scriptProperties,'galTag');
                      $itemCls = $modx->getOption('itemCls',$scriptProperties,'gal-item');
                      
                      /* check for REQUEST vars if property set */
                      if ($modx->getOption('checkForRequestAlbumVar',$scriptProperties,true)) {
                          if (!empty($_REQUEST[$albumRequestVar])) $album = $_REQUEST[$albumRequestVar];
                      }
                      if ($modx->getOption('checkForRequestTagVar',$scriptProperties,true)) {
                          if (!empty($_REQUEST[$tagRequestVar])) $tag = $_REQUEST[$tagRequestVar];
                      }
                      if (empty($album) && empty($tag)) return '';
                      
                      /* build query */
                      $tagc = $modx->newQuery('galTag');
                      $tagc->setClassAlias('TagsJoin');
                      $tagc->select('GROUP_CONCAT('.$modx->getSelectColumns('galTag','TagsJoin','',array('tag')).')');
                      $tagc->where($modx->getSelectColumns('galTag','TagsJoin','',array('item')).' = '.$modx->getSelectColumns('galItem','galItem','',array('id')));
                      $tagc->prepare();
                      $tagSql = $tagc->toSql();
                      
                      $c = $modx->newQuery('galItem');
                      $c->select(array('galItem.*'));
                      $c->select('('.$tagSql.') AS `tags`');
                      $c->innerJoin('galAlbumItem','AlbumItems');
                      $c->innerJoin('galAlbum','Album',$modx->getSelectColumns('galAlbumItem','AlbumItems','',array('album')).' = '.$modx->getSelectColumns('galAlbum','Album','',array('id')));
                      
                      /* pull by album */
                      if (!empty($album)) {
                          $albumField = is_numeric($album) ? 'id' : 'name';
                      
                          $albumWhere = $albumField == 'name' ? array('name' => $album) : $album;
                          $album = $modx->getObject('galAlbum',$albumWhere);
                          if (empty($album)) return '';
                          $c->where(array(
                              'Album.'.$albumField => $album->get($albumField),
                          ));
                          $galleryId = $album->get('id');
                          $galleryName = $album->get('name');
                          $galleryDescription = $album->get('description');
                          unset($albumWhere,$albumField);
                      }
                      if (!empty($tag)) { /* pull by tag */
                          $c->innerJoin('galTag','Tags');
                          $c->where(array(
                              'Tags.tag' => $tag,
                          ));
                          if (empty($album)) {
                              $galleryId = 0;
                              $galleryName = $tag;
                              $galleryDescription = '';
                          }
                      }
                      $c->where(array(
                          'galItem.mediatype' => $modx->getOption('mediatype',$scriptProperties,'image'),
                      ));
                      if (!$showInactive) {
                          $c->where(array(
                              'galItem.active' => true,
                          ));
                      }
                      
                      if (strcasecmp($sort,'rand')==0) {
                          $c->sortby('RAND()',$dir);
                      } else {
                          $c->sortby($sortAlias.'.'.$sort,$dir);
                      }
                      if (!empty($limit)) $c->limit($limit,$start);
                      $items = $modx->getCollection('galItem',$c);
                      
                      /* load plugins */
                      if (!empty($plugin)) {
                          if (($className = $modx->loadClass('gallery.plugins.'.$plugin,$gallery->config['modelPath'],true,true))) {
                              $plugin = new $className($gallery,$scriptProperties);
                              $plugin->load();
                              $scriptProperties = $plugin->adjustSettings($scriptProperties);
                          }
                      } else {
                          if ($modx->getOption('useCss',$scriptProperties,true)) {
                              $modx->regClientCSS($gallery->config['cssUrl'].'web.css');
                          }
                      }
                      
                      /* iterate */
                      $output = '';
                      foreach ($items as $item) {
                          $itemArray = $item->toArray();
                          $itemArray['cls'] = $itemCls;
                          $itemArray['filename'] = basename($item->get('filename'));
                          $itemArray['image_absolute'] = $modx->getOption('gallery.files_url').$item->get('filename');
                          $itemArray['fileurl'] = $itemArray['image_absolute'];
                          $itemArray['filepath'] = $modx->getOption('gallery.files_path').$item->get('filename');
                          $itemArray['filesize'] = $item->get('filesize');
                          $itemArray['thumbnail'] = $item->get('thumbnail',array(
                              'w' => (int)$modx->getOption('thumbWidth',$scriptProperties,100),
                              'h' => (int)$modx->getOption('thumbHeight',$scriptProperties,100),
                              'zc' => (boolean)$modx->getOption('thumbZoomCrop',$scriptProperties,1),
                              'far' => (boolean)$modx->getOption('thumbFar',$scriptProperties,'C'),
                              'q' => $modx->getOption('thumbQuality',$scriptProperties,90),
                          ));
                          $itemArray['image'] = $item->get('thumbnail',array(
                              'w' => (int)$modx->getOption('imageWidth',$scriptProperties,500),
                              'h' => (int)$modx->getOption('imageHeight',$scriptProperties,500),
                              'zc' => (boolean)$modx->getOption('imageZoomCrop',$scriptProperties,false),
                              'far' => (string)$modx->getOption('imageFar',$scriptProperties,''),
                              'q' => $modx->getOption('imageQuality',$scriptProperties,90),
                          ));
                          if (!empty($album)) $itemArray['album'] = $album->get('id');
                          if (!empty($tag)) $itemArray['tag'] = $tag;
                          $itemArray['linkToImage'] = $linkToImage;
                          $itemArray['imageGetParam'] = $imageGetParam;
                          $itemArray['albumRequestVar'] = $albumRequestVar;
                          $itemArray['tagRequestVar'] = $tagRequestVar;
                          $itemArray['tag'] = '';
                      
                          $output .= $gallery->getChunk($modx->getOption('thumbTpl',$scriptProperties,'galItemThumb'),$itemArray);
                      }
                      
                      $containerTpl = $modx->getOption('containerTpl',$scriptProperties,false);
                      if (!empty($containerTpl)) {
                          $ct = $gallery->getChunk($containerTpl,array(
                              'thumbnails' => $output,
                              'album_name' => $galleryName,
                              'album_description' => $galleryDescription,
                          ));
                          if (!empty($ct)) $output = $ct;
                      }
                      
                      $toPlaceholder = $modx->getOption('toPlaceholder',$scriptProperties,false);
                      if (!empty($toPlaceholder)) {
                          $modx->toPlaceholders(array(
                              $toPlaceholder => $output,
                              $toPlaceholder.'.id' => $galleryId,
                              $toPlaceholder.'.name' => $galleryName,
                              $toPlaceholder.'.description' => $galleryDescription,
                          ));
                      } else {
                          $placeholderPrefix = $modx->getOption('placeholderPrefix',$scriptProperties,'gallery.');
                          $modx->toPlaceholders(array(
                              $placeholderPrefix.'id' => $galleryId,
                              $placeholderPrefix.'name' => $galleryName,
                              $placeholderPrefix.'description' => $galleryDescription,
                          ));
                          return $output;
                      }
                      return '';


                      GalleryAlbums
                      <?php
                      /**
                       * Gallery
                       *
                       * Copyright 2010 by Shaun McCormick <[email protected]>
                       *
                       * Gallery is free software; you can redistribute it and/or modify it under the
                       * terms of the GNU General Public License as published by the Free Software
                       * Foundation; either version 2 of the License, or (at your option) any later
                       * version.
                       *
                       * Gallery is distributed in the hope that it will be useful, but WITHOUT ANY
                       * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
                       * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
                       *
                       * You should have received a copy of the GNU General Public License along with
                       * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple
                       * Place, Suite 330, Boston, MA 02111-1307 USA
                       *
                       * @package gallery
                       */
                      /**
                       * Loads a list of Albums
                       *
                       * @package gallery
                       */
                      $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
                      if (!($gallery instanceof Gallery)) return '';
                      
                      /* setup default properties */
                      $rowTpl = $modx->getOption('rowTpl',$scriptProperties,'galAlbumRowTpl');
                      $tplCover = $modx->getOption('albumCover',$scriptProperties,'galAlbumCoverRowTpl');
                      $showInactive = $modx->getOption('showInactive',$scriptProperties,false);
                      $prominentOnly = $modx->getOption('prominentOnly',$scriptProperties,true);
                      $toPlaceholder = $modx->getOption('toPlaceholder',$scriptProperties,false);
                      $sort = $modx->getOption('sort',$scriptProperties,'createdon');
                      $sortAlias = $modx->getOption('sortAlias',$scriptProperties,'galAlbum');
                      $dir = $modx->getOption('dir',$scriptProperties,'DESC');
                      $limit = $modx->getOption('limit',$scriptProperties,10);
                      $start = $modx->getOption('start',$scriptProperties,0);
                      $parent = $modx->getOption('parent',$scriptProperties,0);
                      $showAll = $modx->getOption('showAll',$scriptProperties,false);
                      $albumRequestVar = $modx->getOption('albumRequestVar',$scriptProperties,'galAlbum');
                      $tag = $modx->getOption('tag',$scriptProperties,'');
                      
                      // NOT NECESSARY, MAYBE FOR ANOTHER NEW PROJECT
                      /*$tagc = $modx->newQuery('galItem');
                      $tagc->setClassAlias('ItemsJoin');
                      $tagc->select($modx->getSelectColumns('galItem','ItemsJoin','',array('filename')));
                      $tagc->innerJoin('galAlbumItem','AlbumItems');
                      $tagc->innerJoin('galAlbum','Album',$modx->getSelectColumns('galAlbumItem','AlbumItems','',array('album')).' = '.$modx->getSelectColumns('galAlbum','Album','',array('id')));
                      $tagc->innerJoin('galTag','Tags');
                      $tagc->where($modx->getSelectColumns('galItem','ItemsJoin','',array('id')).' = '.$modx->getSelectColumns('galAlbumItem','AlbumItems','',array('item')));
                         $tagc->where(array(
                              'Tags.tag' => "albumcover"
                          ));
                         $tagc->where(array(
                              'Album.id' => 'galAlbum.'.'id'
                          ));
                      
                      $tagc->prepare();
                      $tagSql = $tagc->toSql();*/
                      
                      /* build query */
                      $c = $modx->newQuery('galAlbum');
                      $c->select(array('galAlbum.*'));
                      
                      if (!$showInactive) {
                          $c->where(array(
                              'active' => true,
                          ));
                      }
                      if ($prominentOnly) {
                          $c->where(array(
                              'prominent' => true,
                          ));
                      }
                      if (empty($showAll)) {
                          $c->where(array(
                              'parent' => $parent,
                          ));
                      }
                      $c->sortby($sortAlias.'.'.$sort,$dir);
                      if ($limit > 0) { $c->limit($limit,$start); }
                      $albums = $modx->getCollection('galAlbum',$c);
                      
                      /* iterate */
                      
                      /* CODE PART ADDED BY greenVisions ([email protected]) BASED ON Shaun McCormick's GALLERYALBUM SNIPPET  */
                      
                      $output = '';
                      foreach ($albums as $album) {
                      	$albumArray = $album->toArray();
                      	$albumArray['totalPictures'] = 0;
                      	$albumItems = $album->getMany('AlbumItems');
                      	foreach ($albumItems as $albumItem) {
                      		$albumArray['totalPictures'] += 1;
                      		$item = $albumItem->getOne('Item');
                      		$tags = $item->getMany('Tags');
                      		foreach ($tags as $tag) {
                      			$tagArray = $tag->toArray();
                      			if(!empty($tagArray) && $tagArray['tag'] = $tag){
                      				
                      				$itemArray = $item->toArray();
                      				$itemArray['filename'] = basename($item->get('filename'));
                      				$itemArray['image_absolute'] = $modx->getOption('gallery.files_url').$item->get('filename');
                      				$itemArray['filesize'] = $item->get('filesize');
                      				$itemArray['thumbnail'] = $item->get('thumbnail',array(
                      					'w' => (int)$modx->getOption('thumbWidth',$scriptProperties,100),
                      					'h' => (int)$modx->getOption('thumbHeight',$scriptProperties,100),
                      					'zc' => (boolean)$modx->getOption('thumbZoomCrop',$scriptProperties,1),
                      					'far' => (boolean)$modx->getOption('thumbFar',$scriptProperties,'C'),
                      				));
                      				$itemArray['image'] = $item->get('thumbnail',array(
                      					'w' => (int)$modx->getOption('imageWidth',$scriptProperties,500),
                      					'h' => (int)$modx->getOption('imageHeight',$scriptProperties,500),
                      					'zc' => (boolean)$modx->getOption('imageZoomCrop',$scriptProperties,false),
                      					'far' => (string)$modx->getOption('imageFar',$scriptProperties,''),
                      				));
                      				
                      				$thumbOutput = $modx->getChunk($tplCover,$itemArray);
                      				$albumArray['albumThumb'] = $thumbOutput;
                      			}
                      		}
                      	}
                          $albumArray['albumRequestVar'] = $albumRequestVar;
                          $output .= $gallery->getChunk($rowTpl,$albumArray);
                      }
                      
                      if ($toPlaceholder) {
                          $modx->setPlaceholder($toPlaceholder,$output);
                          return '';
                      }
                      return $output;


                      GalleryItem
                      <?php
                      /**
                       * Gallery
                       *
                       * Copyright 2010 by Shaun McCormick <[email protected]>
                       *
                       * Gallery is free software; you can redistribute it and/or modify it under the
                       * terms of the GNU General Public License as published by the Free Software
                       * Foundation; either version 2 of the License, or (at your option) any later
                       * version.
                       *
                       * Gallery is distributed in the hope that it will be useful, but WITHOUT ANY
                       * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
                       * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
                       *
                       * You should have received a copy of the GNU General Public License along with
                       * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple
                       * Place, Suite 330, Boston, MA 02111-1307 USA
                       *
                       * @package gallery
                       */
                      /**
                       * Display a single Gallery Item
                       *
                       * @package gallery
                       */
                      $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
                      if (!($gallery instanceof Gallery)) return '';
                      
                      /* get ID of item */
                      $id = (int)$modx->getOption('id',$scriptProperties,false);
                      if ($modx->getOption('checkForRequestVar',$scriptProperties,true)) {
                          $getParam = $modx->getOption('getParam',$scriptProperties,'galItem');
                          if (!empty($_REQUEST[$getParam])) { $id = (int)$_REQUEST[$getParam]; }
                      }
                      if (empty($id)) return '';
                      
                      /* setup default properties */
                      $tpl = $modx->getOption('tpl',$scriptProperties,'galItem');
                      $toPlaceholders = $modx->getOption('toPlaceholders',$scriptProperties,true);
                      $toPlaceholdersPrefix = $modx->getOption('toPlaceholdersPrefix',$scriptProperties,'galitem');
                      $albumTpl = $modx->getOption('albumTpl',$scriptProperties,'galItemAlbum');
                      $albumSeparator = $modx->getOption('albumSeparator',$scriptProperties,', ');
                      $albumRequestVar = $modx->getOption('albumRequestVar',$scriptProperties,'galAlbum');
                      $tagTpl = $modx->getOption('tagTpl',$scriptProperties,'galItemTag');
                      $tagSeparator = $modx->getOption('tagSeparator',$scriptProperties,', ');
                      $tagSortDir = $modx->getOption('tagSortDir',$scriptProperties,'DESC');
                      $tagRequestVar = $modx->getOption('tagRequestVar',$scriptProperties,'galTag');
                      
                      /* get item */
                      $c = $modx->newQuery('galItem');
                      $c->select($modx->getSelectColumns('galItem','galItem'));
                      $c->where(array(
                          'id' => $id,
                      ));
                      $item = $modx->getObject('galItem',$c);
                      if (empty($item)) return '';
                      
                      /* setup placeholders */
                      $itemArray = $item->toArray();
                      $itemArray['filename'] = basename($item->get('filename'));
                      $itemArray['filesize'] = $item->get('filesize');
                      $itemArray['thumbnail'] = $item->get('thumbnail',array(
                          'w' => $modx->getOption('thumbWidth',$scriptProperties,100),
                          'h' => $modx->getOption('thumbHeight',$scriptProperties,100),
                          'zc' => $modx->getOption('thumbZoomCrop',$scriptProperties,0),
                          'far' => $modx->getOption('thumbFar',$scriptProperties,'C'),
                          'q' => $modx->getOption('thumbQuality',$scriptProperties,90),
                      ));
                      $itemArray['image'] = $item->get('thumbnail',array(
                          'w' => $modx->getOption('imageWidth',$scriptProperties,500),
                          'h' => $modx->getOption('imageHeight',$scriptProperties,500),
                          'zc' => $modx->getOption('imageZoomCrop',$scriptProperties,0),
                          'far' => $modx->getOption('imageFar',$scriptProperties,false),
                          'q' => $modx->getOption('imageQuality',$scriptProperties,90),
                      ));
                      
                      /* get albums */
                      $c = $modx->newQuery('galAlbum');
                      $c->innerJoin('galAlbumItem','AlbumItems',$modx->getSelectColumns('galAlbumItem','AlbumItems','',array('album')).' = '.$modx->getSelectColumns('galAlbum','galAlbum','',array('id'))
                          .' AND '.$modx->getSelectColumns('galAlbumItem','AlbumItems','',array('item')).' = '.$item->get('id'));
                      $c->sortby('AlbumItems.rank','ASC');
                      $albums = $modx->getCollection('galAlbum',$c);
                      $itemArray['albums'] = '';
                      $i = 0; $count = count($albums);
                      foreach ($albums as $album) {
                          $albumArray = $album->toArray('',true,true);
                          $albumArray['albumRequestVar'] = $albumRequestVar;
                          $itemArray['albums'] .= $gallery->getChunk($albumTpl,$albumArray);
                          if ($i+1 < $count) $itemArray['albums'] .= $albumSeparator;
                          $i++;
                      }
                      
                      /* get tags */
                      $c = $modx->newQuery('galTag');
                      $c->where(array(
                          'item' => $item->get('id'),
                      ));
                      $c->sortby('tag',$tagSortDir);
                      $tags = $modx->getCollection('galTag',$c);
                      $itemArray['tags'] = '';
                      $i = 0; $count = count($tags);
                      foreach ($tags as $tag) {
                          $tagArray = $tag->toArray();
                          $tagArray['tagRequestVar'] = $tagRequestVar;
                          $itemArray['tags'] .= $gallery->getChunk($tagTpl,$tagArray);
                          if ($i+1 < $count) $itemArray['tags'] .= $tagSeparator;
                          $i++;
                      }
                      
                      /* if outputting to placeholders, use this, otherwise, use tpl */
                      if ($toPlaceholders) {
                          $modx->toPlaceholders($itemArray,$toPlaceholdersPrefix);
                          return '';
                      }
                      
                      if (empty($tpl)) return '';
                      $output .= $gallery->getChunk($tpl,$itemArray);
                      return $output;