Created
February 2, 2015 08:42
-
-
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!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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