in this tuto, I'll show you how to add css classes into a specific image field in Drupal 8.
Add this code to your theme's .theme or your module function:
/**
* @param $variables
*/
function mymodule_preprocess_field(&$variables)
{
if ($variables['element']['#field_name'] == 'field_name') {
foreach (array_keys($variables['items']) as $index) {
$variables['items'][$index]['content']['#item_attributes']['class'][] = 'my-img-class';
}
}
}