diff --git a/uw_cfg_common.module b/uw_cfg_common.module index 4843c0f7e8fa99d47f8c5aa847754c17a8b9c475..3b252cca88dff25b75573a4a2640ee4723d489ce 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -893,14 +893,17 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state, // actual media types in the hero section. if (isset($form['field_uw_type_of_media'])) { - $node_type = str_replace('node_uw_ct_', '' , $form_id); - $node_type = str_replace('_edit', '' , $node_type); - $node_type = str_replace('_form', '' , $node_type); + // Get the node type from the form id. + $node_type = str_replace('node_uw_ct_', '', $form_id); + $node_type = str_replace('_edit', '', $node_type); + $node_type = str_replace('_form', '', $node_type); + // Content types to remove the hero image from media. $remove_hero_image_nodes = [ 'web_page', ]; + // If the node type can not have hero image, remove the option. if (in_array($node_type, $remove_hero_image_nodes)) { unset($form['field_uw_type_of_media']['widget']['#options']['image']); }