From 538c2f2347276939f99837b73c81bed1c4874ed1 Mon Sep 17 00:00:00 2001
From: James Wilson <21588-jwilson3@users.noreply.drupalcode.org>
Date: Mon, 27 May 2024 19:26:23 +0000
Subject: [PATCH] Issue #3450181: Add Label Help support for Core Media
 reference fields

---
 label_help.module | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/label_help.module b/label_help.module
index 6aa815f..4444836 100644
--- a/label_help.module
+++ b/label_help.module
@@ -135,14 +135,16 @@ function label_help_form_alter(&$form, &$form_state, $form_id) {
         }
       }
 
-      // Special case for checkboxes and radios. Drupal's fieldset.html.twig do
-      // not support the #label_prefix, so use #field_prefix instead, but be
-      // careful to not overwrite content when the #field_prefix is already
-      // defined.
+      // Special case for media, checkboxes and radios where Drupal's
+      // fieldset.html.twig does not support the #label_prefix, so use
+      // #field_prefix instead, but be careful to not overwrite content
+      // when the #field_prefix is already defined.
       elseif (
         (
           !empty($item['widget']['#type']) &&
+          !empty($item['widget']['#title']) &&
           (
+            $item['widget']['#type'] == 'fieldset' ||
             $item['widget']['#type'] == 'checkboxes' ||
             $item['widget']['#type'] == 'radios'
           )
-- 
GitLab