Dealing With Media Content
The news
and review
content
types we have looked at so far only have textual content. How do you
deal with media content such as images, video clips and sound files?
There is a link
field type that can be used to
contain references to media objects, so you can use this to create
content types specifically designed for media objects. A
content-type
element is only allowed to contain one
field
of type link
, so you need
to define a number of different content-type
s for
handling different types of media objects.
The temp-dev
content-type
resource contains the following content type definition for image
objects:
<content-type name="image"> <ui:label>Picture</ui:label> <ui:description>An image</ui:description> <ui:title-field>name</ui:title-field> <panel name="default"> <ui:label>Image content</ui:label> <field mime-type="text/plain" type="basic" name="name"> <ui:label>Name</ui:label> <ui:description>The name of the image</ui:description> <constraints> <required>true</required> </constraints> </field> <field mime-type="text/plain" type="basic" name="description"> <ui:label>Description</ui:label> </field> <field mime-type="text/plain" type="basic" name="alttext"> <ui:label>Alternative text</ui:label> </field> <field name="binary" type="link"> <relation>com.escenic.edit-media</relation> <constraints> <mime-type>image/jpeg</mime-type> <mime-type>image/png</mime-type> </constraints> </field> </panel> <panel name="crop"> <ui:label>Crop</ui:label> <field name="alternates" type="basic" mime-type="application/json"> <representations xmlns="http://xmlns.escenic.com/2009/representations" type="image-versions"> <representation name="WideBig"> <output width="572" height="204"/> <crop/> <resize/> </representation> <representation name="SmallSquare"> <output width="150" height="150"/> <crop/> <resize/> </representation> </representations> </field> </panel> <summary> <ui:label>Content Summary</ui:label> <field name="caption" type="basic" mime-type="text/plain"/> <field name="alttext" type="basic" mime-type="text/plain"/> </summary> </content-type>
This content type's "default" panel contains a link
field for the URL of an image file plus three other fields for storing
information about the image: name
,
description
and alttext
.
The "crop" panel contains a field that can be used to set up alternative image versions called representations.
In a typical "newspaper-like" Escenic publication, media objects such as images are usually "secondary" content items that appear embedded in text-based content items. This "embedding" is achieved by means of relations. For more information about this, see Relations.