I have an image field with multiple images, field_sponsors.
I need to be able to set the label of this field programatically. The default label on the field is set to "Sponsors", but sometimes it needs to be labelled differently on output.
I’ve tried this in my .theme file in the preprocess_node function, but it does not work.
$node->set('field_sponsor', array(
'label' => 'BATMAN!',
));
I don’t want to do it in twig because I have 5 different fields to do this for and I need to do multiple checks to determine the correct output text.