Exercise: Override the Image Field Template for Drupal 8, 9, and 10

In this exercise, we'll continue our template overriding practice by overriding the image field template. We'll consult the Bootstrap documentation and add a responsive image class that will apply to any images uploaded by a user to the field_image field. Once again, we'll add this class to the classes array in the set Twig tag. You should work on the exercise steps below first, and you can refer to the video if you need some help.

If you want to try and accomplish this on your own first you'll need to:

  • Override the image field template file.
  • Add values to the classes array with set.

Note: At the end of this exercise, you'll find a video walk-through of the solution.