I'm following this documentation and I'm trying to figure out what other parameter values can the media helper take to render images.
{% media media, 'small' %}
In the above example, the media tag takes two parameters, the first one is the media entity and the second one is the format. However, I don't see the list of values for the format in the documentation.
Since {% media %} is a custom twig tag. I tried to put break points on MediaTokenParser and MediaNode but it doesn't seem to stop on those two places. Can anyone give me some pointers on how to find out the values. Thanks!
You define the formats yourself.
Go to this link and scroll down to the app/config/config.yml
section. By 'default', there are just two formats defined, but you can add your own, and name them according to your preference, like this.
formats:
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
Basically, you can set width
, height
and quality
in the current code.
There's more examples here (they seem to have mixed up the quality
and width
attributes in the TV section).
As a side note, a full text search over the source code is always a good idea. If you happen to use Linux, a quick rgrep "small" * --color
gives you a few pointers to where to look next. rgrep "quality" * --color
pretty much nails it, leading you to the Resizer
classes where these options are processed.