Add classes to an image variable
- Go to Structure>Twig Templates
- Edit the template with the name of the image field as displayed on the Content Type (example: field__field_photo)
- Replace the default classes "dcf-obj-fit-cover unl-frame-quad" with the classes you want applied.
{% for item in items %}
{% set classes = {'class': 'dcf-obj-fit-cover unl-frame-quad'} %}
{% set itemclone = item['#item'] %}
{% set itemclone = itemclone|merge({'attributes': classes}) %}
{% set item = item|merge({'#item': itemclone}) %}
{{ item }}
{% endfor %}