media

Access to data about uploaded files and other media.

The medium (singular form of media) table stores all information of uploaded files or other media. Every resource can contain a single medium. A resource with a medium is most often of the category image, audio, video or document.

In template the m_media model is used to fetch the medium record by the resource id: m.media[id]. This is the same function as with m.rsc[id].medium except, that the m_rsc model does access control checks and the m_media does not.

The m_media model implements all functions to handle media files and is used by other Erlang modules.

Properties of a medium record

A medium record has minimally the following properties, other properties can be added by modules.

PropertyDescriptionExample value
idId of the medium record, equal to the page id.512
filenameFilename and path of the uploaded file, relative to the archive directory.<<”2009/10/20/zotonic-datamodel.jpg”>>
rootnameRoot name of the filename.<<”zotonic-datamodel”>>
original_filenameFilename as suggested by the user agent when uploading the file. Can contain illegal characters.<<”Zotonic-datamodel.jpg”>>
mimeMime type of the medium.<<”image/jpeg”>>
widthWidth in pixels.536
heightHeight in pixels.737
orientationExif oritentation of the image.1
sha1Optional sha1 checksum of uploaded file. Undefined when not present.
sizeSize in bytes of the uploaded file.71585
preview_filenameOptional filename for a generated file preview.
preview_widthOptional. Width of the generated preview.
preview_heightOptional. Height of the generated preview.
is_deletable_fileIf the file should be deleted when the medium record is deleted. A boolean.true
is_deletable_previewIf the optionally generated preview file should be deleted when the medium record is deleted. A boolean.false
createdTimestamp when the medium record is created.\{\{2009,10,20\},\{13,47,27\}\}

Edit on GitHub

category Models identity

Referred by

Media

Resources can have media resources attached to them. Resources and their media (images, video and audio) are connected…