I'm struggling to make template suggestions like IMAGE--BLOCK-TYPE or IMAGE--FIELD-TYPE. I have three different block types(image1, image2, image3) with one image field(field_image_1, field_image_2 and field_image_3). And I don't know how to get suggestion like
image--block_image1.html.twig
image--block_image2.html.twig
image--block_image3.html.twig
or
image--field_image_1.html.twig
image--field_image_2.html.twig
image--field_image_3.html.twig
Is there any way to pass variable between the two hooks below?
function full_nature_theme_suggestions_block_alter(array &$suggestions, array $variables) {
global $block_id;
$block_id = $variables['elements']['#id'];
}
and
function full_nature_theme_suggestions_image_alter(array &$suggestions, array $variables) {
$suggestions[] = 'image__'.$block_id;
}
Please help!