# media\_for\_language

Source: https://zotonic.com/docs/2391/media_for_language

URI: https://zotonic.com/id/2391

Language: en



Filter a list of media items by their `medium_language` property, return the best matching with the current or given language. Only visible media items are returned.

Let’s assume two media resources:

- 13925 with `medium_language` set to `en`
- 13926 with `medium_language` set to `nl`

If the current language is `nl` then:

```erlang
{% print [13926, 13925]|media_for_language %}
```

Will show:

```erlang
[13926]
```

But:

```erlang
{% print [13926, 13925]|media_for_language:"en" %}
```

Will show:

```erlang
[13925]
```

The filter tries to select the *best* matching language for the requested language. If there is no language requested, then the current request language is used.

If a language could not be found then the normal *fallback* language lookup will apply, just as with text translations lookups.

For example, given the above two ids and a request language of `nl` then the following:

```erlang
{% print [13926, 13925]|media_for_language:"de" %}
```

Will print:

```erlang
[13926]
```

This is because there are no German translations. So the system fell back to the request language(s) and selected the Dutch version.

This filter can be used to show all connected media that are in a certain language:

```erlang
{% for media_id in m.edge.o[id].depiction %}
   {% media media_id %}
{% endfor %}
```

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2391?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2391?language=en>)
