Digital Asset Management for all your ProcessWire media

Direct Access of Media in Media Manager Library

You don't need to use a Media Manager inputfield in order to access the content of your Media Manager Library. If you wish to access the Library directly, you can do so using normal ProcessWire API and selectors. This is because, behind the scenes, your media live in real ProcessWire pages. Hence, all you need to know are the names of the templates and fields used by media pages. The respective templates and the fields attached to them are:

Examples

Find a limited number of document media and output them for download.


<?php
  // find a limited number of document media
  // list the media for download, showing the page title, document name and size
  $mediaPages = $pages->find("template=media-manager-document,limit=5");
  $out = "<ol>";
  if($mediaPages->count) {
    foreach($mediaPages as $mediaPage) {
      // media manager document field (single!)
      $document  = $mediaPage->media_manager_document;
      $out .= "<li>{$mediaPage->title} - <a href='{$document->url}'>{$document->name}</a> ({$document->filesizeStr()})</li>";
    }
  }
  $out .="</ol>";
  echo $out;

Find and output a limited number of image media


<?php
  // find a limited number of image media
  // list the first image per page , showing the page title and image thumb
  $mediaPages = $pages->find("template=media-manager-image,limit=6");
  $out .= "<div class='uk-child-width-expand@s uk-text-center' uk-grid>";
  if($mediaPages->count) {
    // using the each() syntax
    $out .= $mediaPages->each(function($mediaPage) {
      // media manager image field (multi!)
      $images  = $mediaPage->media_manager_image;
      // if we have images, get the first, return its thumb
      if($images->count) {
        $thumb = $images->first()->height(300);
        $out =
          "<div>" .
            "<div class='uk-card uk-card-default uk-card-body'>" .
              "<h3 class='uk-card-title'>{$mediaPage->title}</h3>" .
              "<img src='{$thumb->url}' alt='{$thumb->description}'>".
            "</div>".
          "</div>";
      }

      return $out;
    });

  }

  $out .="</div>";

  echo $out;

Find images by tags


  <?php
  // find images by tag
  $mediaPages = $pages->find("template=$tpl,limit=20, media_manager_image.tags*=asia|africa");