Add classes to an image variable

  1. Go to Structure>Twig Templates
  2. Edit the template with the name of the image field as displayed on the Content Type (example: field__field_photo)
  3. 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 %}