I had a devil of a time figuring out where captioning was coming from on my entity embeds.
Another team member had set it up, and I was just kind of baffled as to why captions were being offered on my entity embed forms.
It turns out that if you turn on captioning, you just get it for free on all of your embeds, and it's not configurable.
But... I don't want it for free!
Bah. Humbug. This free software doesn't have the features I think it should.
Alright, so here's how you turn off captioning:
/** * Implements hook_form_alter(). */ function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { // Disable captioning on paragraph embeds if (isset($form['attributes']['data-caption'])) { if ($form['attributes']['data-entity-type']['#value'] == 'paragraph') { unset($form['attributes']['data-caption']); } } }
Or, you could do it this way, only allowing captioning on Media embeds:
/** * Implements hook_form_alter(). */ function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { // Disable captioning on non-media embeds if (isset($form['attributes']['data-caption'])) { if ($form['attributes']['data-entity-type']['#value'] !== 'media') { unset($form['attributes']['data-caption']); } } }
If you want to find a particular bundle, dump this out (with kint from devel module):
ksm($form['attributes']['data-entity-type']);