Skip to content
pkamps edited this page May 18, 2016 · 3 revisions

#Mugo DAM extension

mugo_dam stands for Mugo Digital Asset Manager. It has 2 parts: the Mugo DAM Server and this eZ Publish extension (client side integration to access the DAM Server). This eZ Publish extension comes with a new datatype for images. The datatype features an enhanced image upload interface supporting drag and drop of images.

Images uploaded by the user do not get stored in the usual way eZ Publish stores content images; instead, images are stored on the Digital Asset Server. The Digital Asset Server is a separate service (idependent of eZ Publish) supporting image-uploading and image-serving in different formats (similar to eZ Publish's image aliases).

##The datatype The eZ Publish datatype is called 'dam_images'. It is responsible to store the references to the images on the image server -- it is not storing the images locally. The datatype stores those references in an associated array:

array( 'standard' => '/link/to/image.jpg', 'square' => '/link/to/square_image.jpg', )

The array key is the ratio identifier 'standard' or 'square'. So a single attribute instance is able to store multiple images (that's different to the eZ Publish standard image datatype). Do not confuse 'ratio' with image aliases. Because each ratio has one original image the user uploads - and for each ratio image you can have multiple image aliases. This associated array gets serialized and stored in the 'data_text' field in the database.

##The attribute_view_gui template

In the templates you can use the attribute_view_gui to render an image. Following parameters are supported:

  • image_alias
  • image_ratio_identifier

Please write your own view template if you need a more complex solution to render img tags. An alternative is to use a template operator called 'image_url'. You'd execute the operator on a DAM image attribute and you have to option to specify 3 parameters:

  • alias
  • image_ratio_identifier
  • protocol ('http', 'https', 'none', 'auto')

Here is an example: {def $image_path = $attribute|image_url( 's300x200', 'standard', 'none' )}

It would produce a URL similar to '//images.domain.com/path/to/image.jpg?alias=s300x200

##Image aliases The image server (not part of this extension) is responsible to generate the image aliases. That's why it's not required that you configure image alias definition in eZ Publish anymore. There is an exception, because if you allow embed images in the ezxmltext attribute, the UI allows you to pick which alias to use for the embedded image. The UI shows a dropdown box for those options and it reads the ezp settings for that. So, it's probably a good idea to configure the image alias definition both on the image server and in ezpublish.

##Class MugoDamFunctionCollection This class is part of this extension, it contains some helper function to communicate with the image server. So if an editor uploads a new image in the admin UI, the datatype will use this class to upload (using curl) the image the the image server. On publish, the datatype will execute a 'rename' on the image server. It will rename the image on the image server, so that it contains the object name in the image file.

##Import data with the 'fromString' method The datatype implements the fromString (and also toString) method. The string is the serialized from of the content in the DB field data_text. See more under 'The datatype' headline. The fromString method can handle remote image if you specify its URL.

##Useful functions in PHP

###MugoDamFunctionCollection::uploadToDam( $imagePath, $fileName = null, $creationTime = null ) It will upload a given $imagePath (with optional fileName and creationTime) to the image server. The imagePath can be a local image or remote image specified as a URL.

###dam_imagesType::getImageUrlByAttribute( $contentObjectAttribute, $alias = null, $image_ratio_identifier = 'standard', $protocol = 'none' ) Returns an image URL based on the given eZ Attribute, alias, ratio identifier and protocol.

##ezfind and mugo_dam The extension comes with a handler class 'ezfSolrDocumentFieldDamImages' to implement to logic how the referenced images are index in solr.

##uploadHandler eZ Publish allows to develop custom upload handlers. That handler is used in various editorial operations, for example if you upload an image in an exzmltext attribute, or if an editor uploads an image via webdav. mugo_dam comes with a custom uploadHandler which will make sure the image ends up on the image server.

##Settings All settings have inline documentation, have a look here: https://github.com/mugoweb/mugo_dam/blob/master/settings/mugo_dam.ini

##Data migration The extension contains a migration script "MugoMigrateImages" to move images from the standard ezp attribute to the new datatype attribute. That script is written as a 'Mugo Task' and you would need to mugo_queue extension to execute it. You need to edit that script to specify the mapping of old to new attributes.

Clone this wiki locally