General

  eZ Systems Website
  Technical documentation
  Editor documentation

This Documentation contains:
 
Technical documentation:



⚠ WARNING ! This documentation is deprecated !

Please go to the current Technical Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

...

Table of Contents
minLevel2

Description

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

...

Info

Note that both Media and BinaryFile Value and Type inherit from the BinaryBase abstract field type, Field Type and share common properties.

PropertyTypeDescriptionExample
idstring

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

This attribute has been introduced in eZ Publish 5.2.

application/63cd472dd7819da7b75e8e2fee507c68.mp4
fileNamestringThe human-readable file name, as exposed to the outside. Used when sending the file for download in order to name the file.butterflies.mp4
fileSizeintFile size, in bytes.1077923
mimeTypestringThe file's mime type.

video/mp4

uristring

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

This attribute has been introduced in eZ Publish 5.2.

The URI is not publicly readable, and must NOT be used to link to the file for download. Use ez_render_field to generate a valid link to the download controller.

/var/ezdemo_site/storage/original/application/63cd472dd7819da7b75e8e2fee507c68.mp4
hasControllerboolean

If Whether the media has a controller when being displayed.

true
autoplayboolean

If Whether the media should be automatically played.

true
loopboolean

If Whether the media should be played in a loop.

false
heightint

Height of the media.

300
widthint

Width of the media.

400
pathstring

deprecated
Renamed to id starting from eZ Publish 5.2. Can still be used, but it is recommended not to use it anymore as it will be removed.

 

...

  • id
  • path (for backwards compatibility)
  • fileName
  • fileSize
  • mimeType
  • uri
  • hasController
  • autoplay
  • loop
  • height
  • width

Validation

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

Name
Type
Default value
Description
maxFileSizeintfalseMaximal Maximum size of the file in bytes.
Code Block
languagephp
titleExample of using Media FieldType Field Type validator in PHP
linenumberstrue
use eZ\Publish\Core\FieldType\Media\Type;
 
$contentTypeService = $repository->getContentTypeService();
$mediaFieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( "media", "ezmedia" );

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

Settings

The FieldType Field Type supports mediaType setting, defining how the media file should be handled in output.

...

Code Block
languagephp
titleExample of using Media FieldType Field Type settings in PHP
linenumberstrue
use eZ\Publish\Core\FieldType\Media\Type;
 
$contentTypeService = $repository->getContentTypeService();
$mediaFieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( "media", "ezmedia" );

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