/doc/core/m_media.html
https://code.google.com/p/zotonic/ · HTML · 154 lines · 129 code · 25 blank · 0 comment · 0 complexity · 1e47141b2d871f8c7a69b4d80edcae60 MD5 · raw file
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Module m_media</title>
- <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
- </head>
- <body bgcolor="white">
- <div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
- <hr>
- <h1>Module m_media</h1>
- <ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Model for medium database.
- <p>Copyright 2009 Marc Worrell
- Date: 2009-04-09
- </p>
- <p><b>Behaviours:</b> <a href="gen_model.html"><tt>gen_model</tt></a>.</p>
- <p><b>Authors:</b> Marc Worrell (<a href="mailto:marc@worrell.nl"><tt>marc@worrell.nl</tt></a>).</p>
- <h2><a name="description">Description</a></h2>Model for medium database
- <h2><a name="index">Function Index</a></h2>
- <table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#delete-2">delete/2</a></td><td>Delete the medium at the id.</td></tr>
- <tr><td valign="top"><a href="#depiction-2">depiction/2</a></td><td>Get the medium record that depicts the resource id.</td></tr>
- <tr><td valign="top"><a href="#depicts-2">depicts/2</a></td><td>Return the list of resources that is depicted by the medium (excluding the rsc itself).</td></tr>
- <tr><td valign="top"><a href="#exists-2">exists/2</a></td><td>Check if a medium record exists.</td></tr>
- <tr><td valign="top"><a href="#get-2">get/2</a></td><td>Get the medium record with the id.</td></tr>
- <tr><td valign="top"><a href="#get_by_filename-2">get_by_filename/2</a></td><td>Fetch a medium by filename.</td></tr>
- <tr><td valign="top"><a href="#identify-2">identify/2</a></td><td>Return the identification of a medium.</td></tr>
- <tr><td valign="top"><a href="#insert_file-2">insert_file/2</a></td><td>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.</td></tr>
- <tr><td valign="top"><a href="#insert_file-3">insert_file/3</a></td><td></td></tr>
- <tr><td valign="top"><a href="#insert_url-2">insert_url/2</a></td><td>Make a new resource for the file based on a URL.</td></tr>
- <tr><td valign="top"><a href="#insert_url-3">insert_url/3</a></td><td></td></tr>
- <tr><td valign="top"><a href="#m_find_value-3">m_find_value/3</a></td><td>Fetch the value for the key from a model source.</td></tr>
- <tr><td valign="top"><a href="#m_to_list-2">m_to_list/2</a></td><td>Transform a m_config value to a list, used for template loops.</td></tr>
- <tr><td valign="top"><a href="#m_value-2">m_value/2</a></td><td>Transform a model value so that it can be formatted or piped through filters.</td></tr>
- <tr><td valign="top"><a href="#replace-3">replace/3</a></td><td>Replace or insert a medium record for the page.</td></tr>
- <tr><td valign="top"><a href="#replace_file-3">replace_file/3</a></td><td>Replaces a medium file, when the file is not in archive then a copy is made in the archive.</td></tr>
- <tr><td valign="top"><a href="#replace_file-4">replace_file/4</a></td><td></td></tr>
- <tr><td valign="top"><a href="#replace_file-5">replace_file/5</a></td><td></td></tr>
- <tr><td valign="top"><a href="#replace_url-4">replace_url/4</a></td><td></td></tr>
- <tr><td valign="top"><a href="#save_preview-4">save_preview/4</a></td><td>Save a preview for a medium record.</td></tr>
- </table>
- <h2><a name="functions">Function Details</a></h2>
- <h3 class="function"><a name="delete-2">delete/2</a></h3>
- <div class="spec">
- <p><tt>delete(Id::RscId, Context) -> ok | {error, Reason}</tt></p>
- </div><p>Delete the medium at the id. The file is queued for later deletion.</p>
- <h3 class="function"><a name="depiction-2">depiction/2</a></h3>
- <div class="spec">
- <p><tt>depiction(Id::RscId, Context) -> PropList | undefined</tt></p>
- </div><p>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.</p>
- <h3 class="function"><a name="depicts-2">depicts/2</a></h3>
- <div class="spec">
- <p><tt>depicts(Id::RscId, Context) -> [Id]</tt></p>
- </div><p>Return the list of resources that is depicted by the medium (excluding the rsc itself)</p>
- <h3 class="function"><a name="exists-2">exists/2</a></h3>
- <div class="spec">
- <p><tt>exists(Name, Context) -> any()</tt></p>
- </div><p>Check if a medium record exists</p>
- <h3 class="function"><a name="get-2">get/2</a></h3>
- <div class="spec">
- <p><tt>get(Id::RscId, Context) -> PropList</tt></p>
- </div><p>Get the medium record with the id</p>
- <h3 class="function"><a name="get_by_filename-2">get_by_filename/2</a></h3>
- <div class="spec">
- <p><tt>get_by_filename(Filename, Context) -> any()</tt></p>
- </div><p>Fetch a medium by filename</p>
- <h3 class="function"><a name="identify-2">identify/2</a></h3>
- <div class="spec">
- <p><tt>identify(Id::ImageFilePath, Context) -> {ok, PropList} | {error, Reason}</tt></p>
- </div><p>Return the identification of a medium. Used by z_media_identify:identify()</p>
- <h3 class="function"><a name="insert_file-2">insert_file/2</a></h3>
- <div class="spec">
- <p><tt>insert_file(File, Context) -> {ok, Id} | {error, Reason}</tt></p>
- </div><p>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</p>
- <h3 class="function"><a name="insert_file-3">insert_file/3</a></h3>
- <div class="spec">
- <p><tt>insert_file(Upload, Props, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="insert_url-2">insert_url/2</a></h3>
- <div class="spec">
- <p><tt>insert_url(Url::File, Context) -> {ok, Id} | {error, Reason}</tt></p>
- </div><p>Make a new resource for the file based on a URL.</p>
- <h3 class="function"><a name="insert_url-3">insert_url/3</a></h3>
- <div class="spec">
- <p><tt>insert_url(Url, Props, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="m_find_value-3">m_find_value/3</a></h3>
- <div class="spec">
- <p><tt>m_find_value(Id::Key, M::Source, Context) -> term()</tt></p>
- </div><p>Fetch the value for the key from a model source</p>
- <h3 class="function"><a name="m_to_list-2">m_to_list/2</a></h3>
- <div class="spec">
- <p><tt>m_to_list(M::Source, Context) -> List</tt></p>
- </div><p>Transform a m_config value to a list, used for template loops</p>
- <h3 class="function"><a name="m_value-2">m_value/2</a></h3>
- <div class="spec">
- <p><tt>m_value(M::Source, Context) -> term()</tt></p>
- </div><p>Transform a model value so that it can be formatted or piped through filters</p>
- <h3 class="function"><a name="replace-3">replace/3</a></h3>
- <div class="spec">
- <p><tt>replace(Id, Props, Context) -> ok | {error, Reason}</tt></p>
- </div><p>Replace or insert a medium record for the page. This is useful for non-file related media.
- Resets all non mentioned attributes.</p>
- <h3 class="function"><a name="replace_file-3">replace_file/3</a></h3>
- <div class="spec">
- <p><tt>replace_file(File, RscId, Context) -> {ok, Id} | {error, Reason}</tt></p>
- </div><p>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.</p>
- <h3 class="function"><a name="replace_file-4">replace_file/4</a></h3>
- <div class="spec">
- <p><tt>replace_file(File, RscId, Props, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="replace_file-5">replace_file/5</a></h3>
- <div class="spec">
- <p><tt>replace_file(File, RscId, Props, PropsMedia, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="replace_url-4">replace_url/4</a></h3>
- <div class="spec">
- <p><tt>replace_url(Url, RscId, Props, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="save_preview-4">save_preview/4</a></h3>
- <div class="spec">
- <p><tt>save_preview(RscId, Data, Mime, Context) -> any()</tt></p>
- </div><p>Save a preview for a medium record. The data is saved to a file in the archive directory.</p>
- <hr>
- <div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
- <p><i>Generated by EDoc, Aug 12 2011, 20:01:40.</i></p>
- </body>
- </html>