/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

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Module m_media</title>
  5. <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
  6. </head>
  7. <body bgcolor="white">
  8. <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>
  9. <hr>
  10. <h1>Module m_media</h1>
  11. <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.
  12. <p>Copyright Š 2009 Marc Worrell
  13. Date: 2009-04-09
  14. </p>
  15. <p><b>Behaviours:</b> <a href="gen_model.html"><tt>gen_model</tt></a>.</p>
  16. <p><b>Authors:</b> Marc Worrell (<a href="mailto:marc@worrell.nl"><tt>marc@worrell.nl</tt></a>).</p>
  17. <h2><a name="description">Description</a></h2>Model for medium database
  18. <h2><a name="index">Function Index</a></h2>
  19. <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>
  20. <tr><td valign="top"><a href="#depiction-2">depiction/2</a></td><td>Get the medium record that depicts the resource id.</td></tr>
  21. <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>
  22. <tr><td valign="top"><a href="#exists-2">exists/2</a></td><td>Check if a medium record exists.</td></tr>
  23. <tr><td valign="top"><a href="#get-2">get/2</a></td><td>Get the medium record with the id.</td></tr>
  24. <tr><td valign="top"><a href="#get_by_filename-2">get_by_filename/2</a></td><td>Fetch a medium by filename.</td></tr>
  25. <tr><td valign="top"><a href="#identify-2">identify/2</a></td><td>Return the identification of a medium.</td></tr>
  26. <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>
  27. <tr><td valign="top"><a href="#insert_file-3">insert_file/3</a></td><td></td></tr>
  28. <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>
  29. <tr><td valign="top"><a href="#insert_url-3">insert_url/3</a></td><td></td></tr>
  30. <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>
  31. <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>
  32. <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>
  33. <tr><td valign="top"><a href="#replace-3">replace/3</a></td><td>Replace or insert a medium record for the page.</td></tr>
  34. <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>
  35. <tr><td valign="top"><a href="#replace_file-4">replace_file/4</a></td><td></td></tr>
  36. <tr><td valign="top"><a href="#replace_file-5">replace_file/5</a></td><td></td></tr>
  37. <tr><td valign="top"><a href="#replace_url-4">replace_url/4</a></td><td></td></tr>
  38. <tr><td valign="top"><a href="#save_preview-4">save_preview/4</a></td><td>Save a preview for a medium record.</td></tr>
  39. </table>
  40. <h2><a name="functions">Function Details</a></h2>
  41. <h3 class="function"><a name="delete-2">delete/2</a></h3>
  42. <div class="spec">
  43. <p><tt>delete(Id::RscId, Context) -&gt; ok | {error, Reason}</tt></p>
  44. </div><p>Delete the medium at the id. The file is queued for later deletion.</p>
  45. <h3 class="function"><a name="depiction-2">depiction/2</a></h3>
  46. <div class="spec">
  47. <p><tt>depiction(Id::RscId, Context) -&gt; PropList | undefined</tt></p>
  48. </div><p>Get the medium record that depicts the resource id. "depiction" Predicates are preferred, when
  49. they are missing then the attached medium record itself is returned. We must be able to generate a preview
  50. from the medium.</p>
  51. <h3 class="function"><a name="depicts-2">depicts/2</a></h3>
  52. <div class="spec">
  53. <p><tt>depicts(Id::RscId, Context) -&gt; [Id]</tt></p>
  54. </div><p>Return the list of resources that is depicted by the medium (excluding the rsc itself)</p>
  55. <h3 class="function"><a name="exists-2">exists/2</a></h3>
  56. <div class="spec">
  57. <p><tt>exists(Name, Context) -&gt; any()</tt></p>
  58. </div><p>Check if a medium record exists</p>
  59. <h3 class="function"><a name="get-2">get/2</a></h3>
  60. <div class="spec">
  61. <p><tt>get(Id::RscId, Context) -&gt; PropList</tt></p>
  62. </div><p>Get the medium record with the id</p>
  63. <h3 class="function"><a name="get_by_filename-2">get_by_filename/2</a></h3>
  64. <div class="spec">
  65. <p><tt>get_by_filename(Filename, Context) -&gt; any()</tt></p>
  66. </div><p>Fetch a medium by filename</p>
  67. <h3 class="function"><a name="identify-2">identify/2</a></h3>
  68. <div class="spec">
  69. <p><tt>identify(Id::ImageFilePath, Context) -&gt; {ok, PropList} | {error, Reason}</tt></p>
  70. </div><p>Return the identification of a medium. Used by z_media_identify:identify()</p>
  71. <h3 class="function"><a name="insert_file-2">insert_file/2</a></h3>
  72. <div class="spec">
  73. <p><tt>insert_file(File, Context) -&gt; {ok, Id} | {error, Reason}</tt></p>
  74. </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>
  75. <h3 class="function"><a name="insert_file-3">insert_file/3</a></h3>
  76. <div class="spec">
  77. <p><tt>insert_file(Upload, Props, Context) -&gt; any()</tt></p>
  78. </div>
  79. <h3 class="function"><a name="insert_url-2">insert_url/2</a></h3>
  80. <div class="spec">
  81. <p><tt>insert_url(Url::File, Context) -&gt; {ok, Id} | {error, Reason}</tt></p>
  82. </div><p>Make a new resource for the file based on a URL.</p>
  83. <h3 class="function"><a name="insert_url-3">insert_url/3</a></h3>
  84. <div class="spec">
  85. <p><tt>insert_url(Url, Props, Context) -&gt; any()</tt></p>
  86. </div>
  87. <h3 class="function"><a name="m_find_value-3">m_find_value/3</a></h3>
  88. <div class="spec">
  89. <p><tt>m_find_value(Id::Key, M::Source, Context) -&gt; term()</tt></p>
  90. </div><p>Fetch the value for the key from a model source</p>
  91. <h3 class="function"><a name="m_to_list-2">m_to_list/2</a></h3>
  92. <div class="spec">
  93. <p><tt>m_to_list(M::Source, Context) -&gt; List</tt></p>
  94. </div><p>Transform a m_config value to a list, used for template loops</p>
  95. <h3 class="function"><a name="m_value-2">m_value/2</a></h3>
  96. <div class="spec">
  97. <p><tt>m_value(M::Source, Context) -&gt; term()</tt></p>
  98. </div><p>Transform a model value so that it can be formatted or piped through filters</p>
  99. <h3 class="function"><a name="replace-3">replace/3</a></h3>
  100. <div class="spec">
  101. <p><tt>replace(Id, Props, Context) -&gt; ok | {error, Reason}</tt></p>
  102. </div><p>Replace or insert a medium record for the page. This is useful for non-file related media.
  103. Resets all non mentioned attributes.</p>
  104. <h3 class="function"><a name="replace_file-3">replace_file/3</a></h3>
  105. <div class="spec">
  106. <p><tt>replace_file(File, RscId, Context) -&gt; {ok, Id} | {error, Reason}</tt></p>
  107. </div><p>Replaces a medium file, when the file is not in archive then a copy is made in the archive.
  108. When the resource is in the media category, then the category is adapted depending on the mime type of the uploaded file.</p>
  109. <h3 class="function"><a name="replace_file-4">replace_file/4</a></h3>
  110. <div class="spec">
  111. <p><tt>replace_file(File, RscId, Props, Context) -&gt; any()</tt></p>
  112. </div>
  113. <h3 class="function"><a name="replace_file-5">replace_file/5</a></h3>
  114. <div class="spec">
  115. <p><tt>replace_file(File, RscId, Props, PropsMedia, Context) -&gt; any()</tt></p>
  116. </div>
  117. <h3 class="function"><a name="replace_url-4">replace_url/4</a></h3>
  118. <div class="spec">
  119. <p><tt>replace_url(Url, RscId, Props, Context) -&gt; any()</tt></p>
  120. </div>
  121. <h3 class="function"><a name="save_preview-4">save_preview/4</a></h3>
  122. <div class="spec">
  123. <p><tt>save_preview(RscId, Data, Mime, Context) -&gt; any()</tt></p>
  124. </div><p>Save a preview for a medium record. The data is saved to a file in the archive directory.</p>
  125. <hr>
  126. <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>
  127. <p><i>Generated by EDoc, Aug 12 2011, 20:01:40.</i></p>
  128. </body>
  129. </html>