{"result":{"depiction_url":null,"edges":{"in_module":{"objects":[{"created":"2023-11-16T08:23:39Z","object_id":{"id":1296,"is_a":["text","documentation","reference","module"],"name":"doc_module_mod_base","title":"mod_base","uri":"https:\/\/zotonic.com\/id\/1296"},"seq":1000000}],"predicate":{"id":333,"is_a":["meta","predicate"],"name":"in_module","title":{"_type":"trans","tr":{"en":"In module"}},"uri":"https:\/\/zotonic.com\/id\/in_module"}},"relation":{"objects":[{"created":"2023-11-16T08:23:39Z","object_id":{"id":1342,"is_a":["text","documentation","reference","template_filter"],"name":"doc_template_filter_filter_show_media","title":"show_media","uri":"https:\/\/zotonic.com\/id\/1342"},"seq":1000000},{"created":"2023-11-16T08:23:39Z","object_id":{"id":1909,"is_a":["text","documentation","reference","template_filter"],"name":"doc_template_filter_filter_embedded_media","title":"embedded_media","uri":"https:\/\/zotonic.com\/id\/1909"},"seq":1000000},{"created":"2023-11-16T08:23:39Z","object_id":{"id":1908,"is_a":["text","documentation","reference","template_filter"],"name":"doc_template_filter_filter_without_embedded_media","title":"without_embedded_media","uri":"https:\/\/zotonic.com\/id\/1908"},"seq":1000000}],"predicate":{"id":303,"is_a":["meta","predicate"],"name":"relation","title":{"_type":"trans","tr":{"nl":"Relatie","en":"Relation"}},"uri":"http:\/\/purl.org\/dc\/terms\/relation"}},"subject":{"objects":[{"created":"2026-09-09T13:48:06Z","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:06Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-09T13:48:06Z","object_id":{"id":2588,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_localization_and_translation","title":"Localization and translation","uri":"https:\/\/zotonic.com\/id\/2588"},"seq":3},{"created":"2026-09-09T13:48:06Z","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:06Z","object_id":{"id":2621,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template_filter","title":"Template filter","uri":"https:\/\/zotonic.com\/id\/2621"},"seq":5},{"created":"2026-09-09T13:48:06Z","object_id":{"id":2643,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_query","title":"Query","uri":"https:\/\/zotonic.com\/id\/2643"},"seq":6},{"created":"2026-09-09T13:48:06Z","object_id":{"id":2668,"is_a":["categorization","keyword","keyword_data_type"],"name":"zotonic_topic_language_code","title":"Language code","uri":"https:\/\/zotonic.com\/id\/2668"},"seq":7}],"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":2391,"is_a":["text","documentation","reference","template_filter"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2391"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_template_filter_filter_media_for_language","page_url":{"en":"https:\/\/zotonic.com\/docs\/2391\/media_for_language","x-default":"https:\/\/zotonic.com\/docs\/2391\/media_for_language"},"preview_url":null,"resource":{"version":55,"pivot_location_lat":null,"title":"media_for_language","is_authoritative":true,"body":"<p>Filter a list of media items by their <code>medium_language<\/code> property, return the best matching with the current or given\nlanguage. Only visible media items are returned.<\/p>\n<p>Let’s assume two media resources:<\/p>\n<ul><li>13925 with <code>medium_language<\/code> set to <code>en<\/code><\/li><li>13926 with <code>medium_language<\/code> set to <code>nl<\/code><\/li><\/ul>\n<p>If the current language is <code>nl<\/code> then:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% print [13926, 13925]|media_for_language %}\n<\/code><\/pre>\n<p>Will show:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">[13926]\n<\/code><\/pre>\n<p>But:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% print [13926, 13925]|media_for_language:&quot;en&quot; %}\n<\/code><\/pre>\n<p>Will show:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">[13925]\n<\/code><\/pre>\n<p>The filter tries to select the <em>best<\/em> matching language for the requested language. If there is no language requested,\nthen the current request language is used.<\/p>\n<p>If a language could not be found then the normal <em>fallback<\/em> language lookup will apply, just as with text translations lookups.<\/p>\n<p>For example, given the above two ids and a request language of <code>nl<\/code> then the following:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% print [13926, 13925]|media_for_language:&quot;de&quot; %}\n<\/code><\/pre>\n<p>Will print:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">[13926]\n<\/code><\/pre>\n<p>This is because there are no German translations. So the system fell back to the request language(s) and selected the\nDutch version.<\/p>\n<p>This filter can be used to show all connected media that are in a certain language:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% for media_id in m.edge.o[id].depiction %}\n   {% media media_id %}\n{% endfor %}\n<\/code><\/pre>","slug":"media_for_language","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"003f094f59e5f510084d4a72636fff2732c932c4c7972fc5f0851845e64c5aae","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":325,"is_a":["meta","category"],"name":"template_filter","title":"Filters","uri":"https:\/\/test.zotonic.com\/id\/325"},"doc_source_path":"apps\/zotonic_mod_base\/src\/filters\/filter_media_for_language.erl","publication_start":"2023-11-16T08:23:38Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_mod_base\/src\/filters\/filter_media_for_language.erl","pivot_location_lng":null,"doc_source_kind":"filter","name":"doc_template_filter_filter_media_for_language","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2023-11-16T08:23:30Z","uri":null,"doc_status":"current","is_dependent":false,"erlang_app":"zotonic_mod_base","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":"66cb145eae7002b184e7d8c4c7bba5e53e8248e5\n","erlang_module":"filter_media_for_language","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-10-02T12:40:32Z","title_slug":"media_for_language"},"uri":"https:\/\/zotonic.com\/id\/2391","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2391"}},"status":"ok"}