Media Manager Objects
A Media Manager field returns and object of type MediaManagerArray. This is a WireArray derived object. This means that you also have at your disposal all the powerful methods inherent in the WireArray class.
Similar to a WireArray object, a MediaManagerArray object requires traversal to access its collections. Each item in a MediaManagerArray is an object of type MediaManager.
Each MediaManager object has the following 6 basic properties.
Saved (database) properties
These 2 properties are saved for each MediaManager object:
- id: page ID of the page where the media lives (hidden in admin and not important to know about)
- type: integer denoting media type (1=audio; 2=document; 3=image [for variations this will be 3x, where x is the number of the variation of an original image]; 4=video)
The following 4 properties are generated at runtime, i.e. when a Media Manager field is accessed.
- typeLabel: User-friendly string denoting media type. These are audio, document, image or video.
- media: A ProcessWire Pagimage object for image media or Pagefile object for audio, document and video media types. The objects include all their properties including ext, filesizeStr, height, width, description, tags, filename, basename, etc. Please note that for image media, this is the first image in the images field (media-manager-image) attached to its Media Manager template.
- mediaField: This returns the media field attached to the Media Manager template. For image media, this is a Pageimages object. For audio, document and video media, this is a Pagefile object.
- title: Title of the media (please note that this is the title of the hidden admin page where the media actually lives. It may or may not be the same as the name of the media file itself. This can be used as a user-friendly name for your media.
In addition to the above properties, any additional ProcessWire fields you add to any of the Media Manager templates will be returned in a MediaManager object as $object->name_of_the_field. For instace, a field named date added to the template media-manager-image will be available as $object->date for all media of type image. Please refer to the section on custom properties for more information.