{"result":{"depiction_url":null,"edges":{"in_module":{"objects":[{"created":"2026-09-09T13:48:11Z","object_id":{"id":335,"is_a":["text","documentation","reference","module"],"name":"doc_core","title":"Zotonic Core","uri":"https:\/\/zotonic.com\/id\/335"},"seq":1}],"predicate":{"id":333,"is_a":["meta","predicate"],"name":"in_module","title":{"_type":"trans","tr":{"en":"In module"}},"uri":"https:\/\/zotonic.com\/id\/in_module"}},"subject":{"objects":[{"created":"2026-09-09T13:48:11Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":2},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2576,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_media_management","title":"Media management","uri":"https:\/\/zotonic.com\/id\/2576"},"seq":3},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2619,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_media_resource","title":"Media resource","uri":"https:\/\/zotonic.com\/id\/2619"},"seq":4},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2625,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_model","title":"Model","uri":"https:\/\/zotonic.com\/id\/2625"},"seq":5},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2643,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_query","title":"Query","uri":"https:\/\/zotonic.com\/id\/2643"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1284,"is_a":["text","documentation","reference","model"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1284"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_model_model_media","page_url":{"en":"https:\/\/zotonic.com\/docs\/1284\/media","x-default":"https:\/\/zotonic.com\/docs\/1284\/media"},"preview_url":null,"resource":{"version":3976,"pivot_location_lat":null,"title":"media","is_authoritative":true,"body":"<p>Access to data about uploaded files and other media.<\/p>\n<p>The <code>medium<\/code> (singular form of media) table stores all information of uploaded files or other media. Every resource can\ncontain a single medium. A resource with a medium is most often of the category image, audio, video or document.<\/p>\n<p>In template the <code>m_media<\/code> model is used to fetch the medium record by the resource id: <code>m.media[id]<\/code>. This is the same\nfunction as with <code>m.rsc[id].medium<\/code> except, that the m_rsc model does access control checks and the m_media does not.<\/p>\n<p>The <code>m_media<\/code> model implements all functions to handle media files and is used by other Erlang modules.<\/p>\n<h2>Properties of a medium record<\/h2>\n<p>A medium record has minimally the following properties, other properties can be added by modules.<\/p>\n<table class=\"table\"><thead><tr><th>Property<\/th><th>Description<\/th><th>Example value<\/th><\/tr><\/thead><tbody><tr><td>id<\/td><td>Id of the medium record, equal to the page id.<\/td><td><code>512<\/code><\/td><\/tr><tr><td>filename<\/td><td>Filename and path of the uploaded file, relative to the archive directory.<\/td><td><code>&lt;&lt;&quot;2009\/10\/20\/zotonic-datamodel.jpg&quot;&gt;&gt;<\/code><\/td><\/tr><tr><td>rootname<\/td><td>Root name of the filename.<\/td><td><code>&lt;&lt;&quot;zotonic-datamodel&quot;&gt;&gt;<\/code><\/td><\/tr><tr><td>original_filename<\/td><td>Filename as suggested by the user agent when uploading the file. Can contain illegal characters.<\/td><td><code>&lt;&lt;&quot;Zotonic-datamodel.jpg&quot;&gt;&gt;<\/code><\/td><\/tr><tr><td>mime<\/td><td>Mime type of the medium.<\/td><td><code>&lt;&lt;&quot;image\/jpeg&quot;&gt;&gt;<\/code><\/td><\/tr><tr><td>width<\/td><td>Width in pixels.<\/td><td><code>536<\/code><\/td><\/tr><tr><td>height<\/td><td>Height in pixels.<\/td><td><code>737<\/code><\/td><\/tr><tr><td>orientation<\/td><td>Exif oritentation of the image.<\/td><td><code>1<\/code><\/td><\/tr><tr><td>sha1<\/td><td>Optional sha1 checksum of uploaded file. Undefined when not present.<\/td><td><\/td><\/tr><tr><td>size<\/td><td>Size in bytes of the uploaded file.<\/td><td><code>71585<\/code><\/td><\/tr><tr><td>preview_filename<\/td><td>Optional filename for a generated file preview.<\/td><td><\/td><\/tr><tr><td>preview_width<\/td><td>Optional. Width of the generated preview.<\/td><td><\/td><\/tr><tr><td>preview_height<\/td><td>Optional. Height of the generated preview.<\/td><td><\/td><\/tr><tr><td>is_deletable_file<\/td><td>If the file should be deleted when the medium record is deleted. A boolean.<\/td><td><code>true<\/code><\/td><\/tr><tr><td>is_deletable_preview<\/td><td>If the optionally generated preview file should be deleted when the medium record is deleted. A boolean.<\/td><td><code>false<\/code><\/td><\/tr><tr><td>created<\/td><td>Timestamp when the medium record is created.<\/td><td><code>{{2009,10,20},{13,47,27}}<\/code><\/td><\/tr><\/tbody><\/table>\n<h2>Available Model API Paths<\/h2>\n<table class=\"table\"><thead><tr><th>Method<\/th><th>Path pattern<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>get<\/code><\/td><td><code>\/+id\/...<\/code><\/td><td>Return medium record for resource <code>+id<\/code> when the resource is visible; returns <code>enoent<\/code> for unknown resource and <code>eacces<\/code> when not visible.<\/td><\/tr><tr><td><code>post<\/code><\/td><td><code>\/+id<\/code><\/td><td>Replace medium of existing resource <code>+id<\/code> from payload <code>url<\/code> or uploaded <code>file<\/code> (<code>#upload<\/code>); optional payload <code>rsc<\/code> map updates resource props. No further lookups.<\/td><\/tr><tr><td><code>post<\/code><\/td><td><code>\/<\/code><\/td><td>Create a new resource+medium from payload <code>url<\/code> or uploaded <code>file<\/code> (<code>#upload<\/code>), with optional payload <code>rsc<\/code> properties for the new resource. No further lookups.<\/td><\/tr><tr><td><code>delete<\/code><\/td><td><code>\/+id<\/code><\/td><td>Delete medium linked to resource <code>+id<\/code> (queues file cleanup, emits media events); requires editable resource access. No further lookups.<\/td><\/tr><\/tbody><\/table>\n<p><code>\/+name<\/code> marks a variable path segment. A trailing <code>\/...<\/code> means extra path segments are accepted for further lookups.<\/p>","slug":"media","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"a7155304961fd14e21af901779f1a3348a3ac4ce163db9568a83e58c85ea1dd3","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":322,"is_a":["meta","category"],"name":"model","title":"Models","uri":"https:\/\/test.zotonic.com\/id\/322"},"doc_source_path":"apps\/zotonic_core\/src\/models\/m_media.erl","publication_start":"2023-06-24T08:17:58Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_core\/src\/models\/m_media.erl","pivot_location_lng":null,"doc_source_kind":"model","name":"doc_model_model_media","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2020-05-30T05:47:16Z","uri":null,"doc_status":"current","is_dependent":false,"erlang_app":"zotonic_core","publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"85498256abd162b9bc082d43a90c995844fd4408\n","erlang_module":"m_media","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-09-29T14:40:26Z","title_slug":"media"},"uri":"https:\/\/zotonic.com\/id\/1284","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1284"}},"status":"ok"}