Skip to content

Instantly share code, notes, and snippets.

@sachbearbeiter
Created February 2, 2015 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachbearbeiter/86c6477b4c5e8cebbe98 to your computer and use it in GitHub Desktop.
Save sachbearbeiter/86c6477b4c5e8cebbe98 to your computer and use it in GitHub Desktop.
D8: Theming examples: Theme: New more specific suggestions for the image.html.twig template ... *http://drupal.stackexchange.com/questions/137652/override-image-formatter-html-twig/141340#141340 **Drupal 8 is still Beta - improvements through API modifications are possible!
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYTHEME_theme_suggestions_image_formatter_alter(array &$suggestions, array $variables) {
$entity = $variables['item']->getEntity();
$field_name = $variables['item']->getParent()->getName();
$suggestions[] = 'image_formatter__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment