# Display images with mediaclasses

Source: https://zotonic.com/docs/2945/display-images-with-mediaclasses

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

Language: en

Define reusable image sizes in priv/templates/mediaclass.config and use them in image tags. For example, a local mediaclass can constrain an image's width:

Define reusable image sizes in `priv/templates/mediaclass.config` and use them in image tags. For example, a local mediaclass can constrain an image's width:

```erlang
[
    {garden_card, [{width, 640}]}
].
```

```django
{% image id mediaclass="garden_card" alt=id.title %}
```

Choose a meaningful description for an image when its purpose is not captured by the title. Check both portrait and landscape source images. Cropping is a design decision; do not add it automatically to every size.

Use <a href="/id/1284" class="doc-reference doc-reference-model"><code>model#media</code></a> for media information and <a href="/id/1341" class="doc-reference doc-reference-tag"><code>tag#image</code></a> for rendering. See [Work with uploaded media](/id/2954) and [Build and serve frontend assets](/id/2947).

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2945?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/2945?language=en>)
