Message-ID: <2073664920.3908.1485855851241.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3907_435834096.1485855851241" ------=_Part_3907_435834096.1485855851241 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html The Media FieldType

The Media FieldType

This FieldType represents and handles media (audio/video) binary= file.

Name Internal name Expected input
Media ezmedia mixed

Table of contents:

=20 =20

Description

This FieldType represents and handles media (audio/video) binary file.

It is capable of handling following types of files:

Input expectations

Type Description Example
string Path to the media file. /Users/jane/butterflies.mp4
eZ\Publish\Core\FieldT= ype\Media\Value Media FieldType Value Object= with path to the media file as the value of id property. See Value object section below.

Value object

Properties

eZ\Publish\Core\FieldType\Media\Value = ;offers the following properties.

Note that both Media and Bin= aryFile Value and Type inherit from the Binar= yBase abstract field type, and share common properties.

Property Type Description Example
id string

Media file identifier. This ID = depends on the IO Han= dler that is being used. With the native, default handlers (FileSy= stem and Legacy), the ID is the file path, relative to the binary file stor= age root dir (var/<vardir>/storage/original by default).=

This attribute has been introduced in eZ Publish 5.2.

application/63cd472dd7819da7b75e8e= 2fee507c68.mp4
fileName string The human readable file name, as e= xposed to the outside. Used when sending the file for download in order to = name the file. butterflies.mp4
fileSize int File size, in bytes 1077923
mimeType string The file's mime type.

video/mp4

uri string

The binary file's HTTP uri. If = the URI doesn't include a host or protocol, it applies to the request domai= n.

This attribute has been introduced in eZ Publish 5.2.

The URI is not publicly readable, and must NOT b= e used to link to the file for download. Use ez_render_field to generate a valid link to the download co= ntroller.

/var/ezdemo_site/storage/original/= application/63cd472dd7819da7b75e8e2fee507c68.mp4
hasController boolean

If the media has a contro= ller when being displayed

true
autoplay boolean

If the media should be au= tomatically played

true
loop boolean

If the media should be pl= ayed in a loop

false
height int

Height of the media

300
width int

Width of the media=

400
path string

deprecated
Renamed to id star= ting from eZ Publish 5.2. Can still be used, but it is recommended not to u= se it anymore as it will be removed.

 

Hash format

The hash format mostly matches the value object. It has the following ke= ys:

Validation

The FieldType supports FileSizeValidator, defining maximal size of media file in bytes:

Name
Type
Default value
Description
maxFileSize int false Maximal size of the file in bytes.
Example of using Media FieldType validator in PHP
=20
use eZ\Publish\Core\FieldType\Media\Type;
=20
$contentTypeService =3D $repository->getContentTypeService();
$mediaFieldCreateStruct =3D $contentTypeService->newFieldDefinitionCreat=
eStruct( "media", "ezmedia" );

// Setting maximal file size to 5 megabytes
$mediaFieldCreateStruct->validatorConfiguration =3D array(
    "FileSizeValidator" =3D> array(
        "maxFileSize" =3D> 5 * 1024 * 1024
    )
);
=20

Settings

The FieldType supports mediaType setting d= efining how the media file should be handled in output.

Name
Type
Default value
Description
mediaType mixed
Type::TYPE_HTML5_VIDEO
Type of the media, accepts one of the predefined= constants.

List of all available mediaType const= ants defined in eZ\Pub= lish\Core\FieldType\Media\Type class:

Name
Description
TYPE_FLASH
Adobe Flash
TYPE_QUICKTIME
Apple QuickTime
TYPE_REALPLAYER<=
/pre>
Real Media
TYPE_SILVERLIGHT=
Silverlight
TYPE_WINDOWSMEDIA

Microsoft Windows Media

TYPE_HTML5_VIDEO=
HTML5 Video
TYPE_HTML5_AUDIO=

HTML5 Audio

Example of using Media FieldType settings in PHP
=20
use eZ\Publish\Core\FieldType\Media\Type;
 
$contentTypeService =3D $repository->getContentTypeService();
$mediaFieldCreateStruct =3D $contentTypeService->newFieldDefinitionCreat=
eStruct( "media", "ezmedia" );

// Setting Adobe Flash as the media type
$mediaFieldCreateStruct->fieldSettings =3D array(
    "mediaType" =3D> Type::TYPE_FLASH,
);
=20
------=_Part_3907_435834096.1485855851241--