Module m_media

Model for medium database.

Copyright 2009-2014 Marc Worrell

Behaviours: gen_model.

Authors: Marc Worrell (marc@worrell.nl).

Description

Model for medium database

Function Index

delete/2Delete the medium at the id.
depiction/2Get the medium record that depicts the resource id.
depicts/2Return the list of resources that is depicted by the medium (excluding the rsc itself).
duplicate/3Duplicate the media item from the id to the new-id.
exists/2Check if a medium record exists.
get/2Get the medium record with the id.
get_by_filename/2Fetch a medium by filename.
get_file_data/2Return the contents of the file belonging to the media resource.
identify/2Return the identification of a medium.
insert_file/2Make a new resource for the file, when the file is not in the archive dir then a copy is made in the archive dir.
insert_file/3
insert_file/4
insert_url/2Make a new resource for the file based on a URL.
insert_url/3
insert_url/4
is_unique_file/2
m_find_value/3Fetch the value for the key from a model source.
m_to_list/2Transform a m_config value to a list, used for template loops.
m_value/2Transform a model value so that it can be formatted or piped through filters.
make_preview_unique/3
replace/3Replace or insert a medium record for the page.
replace_file/3Replaces a medium file, when the file is not in archive then a copy is made in the archive.
replace_file/4
replace_file/5
replace_file/6
replace_url/4
replace_url/5
save_preview/4Save a preview for a medium record.

Function Details

delete/2

delete(Id::RscId, Context) -> ok | {error, Reason}

Delete the medium at the id. The file is queued for later deletion.

depiction/2

depiction(Id::RscId, Context) -> PropList | undefined

Get the medium record that depicts the resource id. "depiction" Predicates are preferred, when they are missing then the attached medium record itself is returned. We must be able to generate a preview from the medium.

depicts/2

depicts(Id::RscId, Context) -> [Id]

Return the list of resources that is depicted by the medium (excluding the rsc itself)

duplicate/3

duplicate(FromId, ToId, Context) -> any()

Duplicate the media item from the id to the new-id. Called by m_rsc:duplicate/3

exists/2

exists(Name, Context) -> any()

Check if a medium record exists

get/2

get(Id::RscId, Context) -> PropList

Get the medium record with the id

get_by_filename/2

get_by_filename(Filename, Context) -> any()

Fetch a medium by filename

get_file_data/2

get_file_data(Id, Context) -> any()

Return the contents of the file belonging to the media resource

identify/2

identify(Id::ImageFilePath, Context) -> {ok, PropList} | {error, Reason}

Return the identification of a medium. Used by z_media_identify:identify()

insert_file/2

insert_file(File, Context) -> {ok, Id} | {error, Reason}

Make a new resource for the file, when the file is not in the archive dir then a copy is made in the archive dir

insert_file/3

insert_file(Upload, Props, Context) -> any()

insert_file/4

insert_file(Upload, Props, Options, Context) -> any()

insert_url/2

insert_url(Url::File, Context) -> {ok, Id} | {error, Reason}

Make a new resource for the file based on a URL.

insert_url/3

insert_url(Url, Props, Context) -> any()

insert_url/4

insert_url(Url, Props, Options, Context) -> any()

is_unique_file/2

is_unique_file(Filename, Context) -> any()

m_find_value/3

m_find_value(Id::Key, M::Source, Context) -> term()

Fetch the value for the key from a model source

m_to_list/2

m_to_list(M::Source, Context) -> List

Transform a m_config value to a list, used for template loops

m_value/2

m_value(M::Source, Context) -> term()

Transform a model value so that it can be formatted or piped through filters

make_preview_unique/3

make_preview_unique(RscId::integer() | insert_rsc, Extension::string(), Context::#context{}) -> file:filename()

replace/3

replace(Id, Props, Context) -> ok | {error, Reason}

Replace or insert a medium record for the page. This is useful for non-file related media. Resets all non mentioned attributes.

replace_file/3

replace_file(File, RscId, Context) -> {ok, Id} | {error, Reason}

Replaces a medium file, when the file is not in archive then a copy is made in the archive. When the resource is in the media category, then the category is adapted depending on the mime type of the uploaded file.

replace_file/4

replace_file(File, RscId, Props, Context) -> any()

replace_file/5

replace_file(File, RscId, Props, Opts, Context) -> any()

replace_file/6

replace_file(Upload, RscId, Props, MInfo, Opts, Context) -> any()

replace_url/4

replace_url(Url, RscId, Props, Context) -> any()

replace_url/5

replace_url(Url, RscId, Props, Options, Context) -> any()

save_preview/4

save_preview(RscId, Data, Mime, Context) -> any()

Save a preview for a medium record. The data is saved to a file in the archive directory.


Generated by EDoc, Nov 26 2014, 15:39:35.