diff --git a/uw_cfg_common.module b/uw_cfg_common.module index 0772ca8d1d82e8a931adbf711d1516c879d57de0..4843c0f7e8fa99d47f8c5aa847754c17a8b9c475 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -886,11 +886,25 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state, } } + $node = \Drupal::routeMatch()->getParameter('node'); + // If there is a type of media field, it means that we are // on a node add/edit page, so add the states for the // 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); + + $remove_hero_image_nodes = [ + 'web_page', + ]; + + if (in_array($node_type, $remove_hero_image_nodes)) { + unset($form['field_uw_type_of_media']['widget']['#options']['image']); + } + // Set the states for the hero image. $form['field_uw_hero_image']['#states'] = [ 'visible' => [ @@ -1452,7 +1466,8 @@ function uw_cfg_common_preprocess_html(&$variables): void { */ function _uw_cfg_common_allowed_media_types( FieldStorageConfig $definition, - ContentEntityInterface $entity = NULL, $cacheable + ContentEntityInterface $entity = NULL, + $cacheable ) { return [