Copyright © 2009-2020 Marc Worrell
Behaviours: zotonic_model.
Authors: Marc Worrell (marc@worrell.nl).
media_url() = binary() | string()
delete/2 | Delete the medium at the id. |
depiction/2 | Get the medium record that depicts the resource id. |
depicts/2 | Return the list of resources that is depicted by the medium (excluding the rsc itself). |
download_file/1 | Download a file from a http or data url. |
download_file/2 | |
duplicate/3 | Duplicate the media item from the id to the new-id. |
exists/2 | Check if a medium record exists. |
get/2 | Get the medium record with the id. |
get_by_filename/2 | Fetch a medium by filename. |
identify/2 | Return the identification of a medium. |
insert_file/2 | 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/4 | |
insert_medium/4 | Insert a medium, together with rsc props and an optional preview_url. |
insert_url/2 | Make a new resource for the file based on a URL. |
insert_url/3 | |
insert_url/4 | |
is_unique_file/2 | |
m_get/3 | Fetch the value for the key from a model source. |
make_preview_unique/3 | |
merge/3 | Move a medium between resources, iff the destination doesn't have an associated medium. |
mime_to_category/1 | |
replace/3 | Replace or insert a medium record for the page. |
replace_file/3 | Replaces 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_medium/5 | |
replace_url/4 | |
replace_url/5 | |
reupload/2 | Re-upload a file so that identify and previews are regenerated. |
save_preview/4 | Save a preview for a medium record. |
save_preview_url/3 | Save a new file from a preview_url as the preview of a medium. |
delete(Id::m_rsc:resource_id(), Context::z:context()) -> ok | {error, term()}
Delete the medium at the id. The file is queued for later deletion.
depiction(Id::m_rsc:resource_id(), Context::z:context()) -> map() | 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(Id::m_rsc:resource_id(), Context::z:context()) -> [m_rsc:resource_id()]
Return the list of resources that is depicted by the medium (excluding the rsc itself)
download_file(Url) -> any()
Download a file from a http or data url.
download_file(Url, Options) -> any()
duplicate(FromId::m_rsc:resource(), ToId::m_rsc:resource(), Context::z:context()) -> ok | {error, term()}
Duplicate the media item from the id to the new-id. Called by m_rsc:duplicate/3
exists(Name::undefined | string() | binary() | integer(), Context::z:context()) -> boolean()
Check if a medium record exists. The argument should be undefined, or a (textual) integer.
get(Id::m_rsc:resource_id(), Context::z:context()) -> z_media_identify:media_info() | undefined
Get the medium record with the id
get_by_filename(Filename::binary(), Context::z:context()) -> z_media_identify:media_info() | undefined
Fetch a medium by filename
identify(Id::m_rsc:resource_id(), Context::z:context()) -> {ok, z_media_identify:media_info()} | {error, term()}
Return the identification of a medium. Used by z_media_identify:identify()
insert_file(File::file:filename_all() | #upload{}, Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, term()}
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(File::file:filename_all() | #upload{}, RscProps::m_rsc:props_all(), Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, term()}
insert_file(File::file:filename_all() | #upload{}, RscProps::m_rsc:props_all(), Options::list(), Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, term()}
insert_medium(Medium, RscProps, Options, Context) -> any()
Insert a medium, together with rsc props and an optional preview_url. This is used for importing media
insert_url(Url::media_url(), Context::z:context()) -> {ok, pos_integer()} | {error, term()}
Make a new resource for the file based on a URL.
insert_url(Url::media_url(), RscProps::z_props:props_all(), Context::z:context()) -> {ok, pos_integer()} | {error, term()}
insert_url(Url::media_url(), RscProps::z_props:props_all(), Options::list(), Context::z:context()) -> {ok, pos_integer()} | {error, term()}
is_unique_file(Filename, Context) -> any()
m_get(Rest::list(), Msg::zotonic_model:opt_msg(), Context::z:context()) -> zotonic_model:return()
Fetch the value for the key from a model source
make_preview_unique(RscId::integer() | insert_rsc, Extension::binary(), Context::z:context()) -> file:filename()
merge(WinnerId, LoserId, Context) -> any()
Move a medium between resources, iff the destination doesn't have an associated medium. This is called when merging two resources (and the FromId is subsequently deleted).
mime_to_category(Mime::string() | binary()) -> image | video | audio | document
replace(Id::m_rsc:resource_id(), Props::map(), Context::z:context()) -> ok | {error, term()}
Replace or insert a medium record for the page. This is useful for non-file related media. Resets all non mentioned attributes.
replace_file(File, RscId, Context) -> any()
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(File, RscId, RscProps, Context) -> any()
replace_file(File, RscId, RscProps, Opts, Context) -> any()
replace_file(File, RscId, RscProps, MediaInfo, Opts, Context) -> any()
replace_medium(Medium, RscId, RscProps, Options, Context) -> any()
replace_url(Url, RscId, RscProps, Context) -> any()
replace_url(Url, RscId, RscProps, Options, Context) -> any()
reupload(Id::m_rsc:resource_id(), Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, term()}
Re-upload a file so that identify and previews are regenerated.
save_preview(RscId::m_rsc:resource_id(), Data::iodata(), Mime::binary() | string(), Context::z:context()) -> {ok, file:filename_all()} | {error, eacces | term()}
Save a preview for a medium record. The data is saved to a file in the archive directory.
save_preview_url(RscId, Url, Context) -> any()
Save a new file from a preview_url as the preview of a medium
Generated by EDoc