0

I am using drupal core 8.4.2 and lightning 8.x-2.23. I have a entity referenced image field that I am printing out like this {{ content.field_main_image_2.0 }}. I think there was a change starting in drupal 8.4 that now the image label is displayed above the image even if you set it to hidden in the media image bundle. Looking at the source for theme template suggestions it says this.

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'field' -->
<!-- FILE NAME SUGGESTIONS:
* field--media--name--image.html.twig
* field--media--name.html.twig
* field--media--image.html.twig
 * field--name.html.twig
* field--string.html.twig
x field.html.twig
-->
<!-- BEGIN OUTPUT from 
'themes/contrib/bootstrap/templates/field/field.html.twig' -->

<div class="field field--name-name field--type-string field--label-hidden field--item">name fish</div>

I want to remove the label "name fish" from appearing above the photo. My entity referenced field name is: field_main_image_2 My content type is called: person How should I rename the template named field.html.twig? I tried renaming it to field--field_main_image_2.html.twig and field--field-main-image-2.html.twig, but this didn't work. It says to use this method field--field-foo.html.twig. For now I placed the file field.html.twig in my template folder and it is being used but I dont see where I can remove the label. The template says Available variables: label_hidden: Whether to show the field label or not.

1 Answer 1

1

Starting in Lightning 2.2.4, you can manage the label in the Media Entity's Manage Display tab.

See this issue for more information: https://www.drupal.org/node/2922289

Include patch to omit media name

Until this is fixed in core, it would be good to have the patch from [#2912298: Make media name available on manage display] included so that media name can be removed from display. This is especially crucial for lightning upgrades with existing media embeds.

1
  • I did it with css. I placed the image field inside an element so that I can target the image name and hide it. <figure>{{ content.field_main_image_2.0 }}</figure> the css is: figure .field--name-name{display: none;} I could also do it in the template: themes/contrib/bootstrap/templates/field/field.html.twig. I removed {{ item.content }} Commented Feb 16, 2018 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.