We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7231
    • 4,205 Posts
    I am working on a project which requires a site wide image manager that needs to include custom fields for each image like author and description information. My first instinct was to use a modx document fort each image, which will work out fine but may add more overhead than needed.

    Can MaxiGallery be used as an image manager?
      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

      Something is happening here, but you don't know what it is.
      Do you, Mr. Jones? - [bob dylan]
      • 7923
      • 4,213 Posts
      Yes. You can create a gallery with custom fields to a single document and then in documents, query specific images with MaxiGallery with the &pic_query_ids snippet parameter.

      You can then create a custom template to show the pictures in what ever form you like, for example just return the image tag and create a "wrapper" snippet that runs maxigallery with specific parameters, eg:

      [[GetImage? &picid=`50`]]

      And GetImage snippet is something like:
      <?php
      //MaxiGallery parameters
      $params['pic_query_ids'] = $picid;
      $params['galleryOuterTpl'] = '@CODE:[+maxigallery.pictures+]'; //template defined in code, could be a chunk name also or a path to file
      $params['galleryPictureTpl'] = '@CODE:<div><img src="[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]" title="[+maxigallery.picture.title:htmlent+]" alt="[+maxigallery.picture.title:htmlent+]" /><p>[+maxigallery.picture.title:htmlent+]</p><p>[+maxigallery.picture.descr:htmlent+]</p></div>';
      return $modx->runSnippet('MaxiGallery', $params);
      


      That would return the normal sized picture in this form:

      <div>
      <img src="...... />
      <p>Title text</p>
      <p>Description text</p>
      </div>

      So your customers can use [[GetImage? &picid=`50`]] anywhere they like to get a normal sized picture with ID 50 wrapped in a div with it’s title / descriptions. You can then do multiple wrapper snippets.. for example get GetThumbnail etc..

      The images can be managed in a single gallery, or multiple. It’s all the same when querying them using picture IDs.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."