media_main does not turn up in views

Created on 22 February 2020, almost 5 years ago
Updated 30 December 2023, 12 months ago

Varbase Media Header (vmh) does not provide sufficient installation of media_field so it can be used in views.

If I follow the following steps
1) Fresh install of varbase and varbase_media_header
2) /admin/config/varbase/varbase-media-header and select 'Basic page'
3) Add a video as remote video
4) Add a basic page with video as VMH video
5) Check: /admin/structure/types/manage/page/fields has field Main media (field_media)
6) Add a view of content: basic page and display unformatted list of fields:
6 a) Try to add the field Main media (field_media) and it is not listed.

7) If I now change docroot/modules/contrib/varbase_media_header/src/Form/VarbaseMediaHeaderSettingsForm.php lines 121->131 to

   $label = "Main Media";
            $type = $bundle_key;
            $field_storage = \Drupal\field\Entity\FieldStorageConfig::loadByName('node', 'field_media');
            $field = \Drupal\field\Entity\FieldConfig::loadByName('node', $type, 'field_media');
            if (empty($field)) {
              $field = \Drupal\field\Entity\FieldConfig::create([
                'field_storage' => $field_storage,
                'bundle' => $type,
                'label' => $label,
                'settings' =>
                  array (
                    'handler' => 'default:media',
                    'handler_settings' =>
                      array (
                        'target_bundles' =>
                          array (
                            'image' => 'image',
                            'remote_video' => 'remote_video',
                            'video' => 'video',
                          ),
                        'sort' =>
                          array (
                            'field' => '_none',
                          ),
                        'auto_create' => false,
                        'auto_create_bundle' => 'remote_video',
                      ),
                  ),
              ]);
              $field->save();
            }

8) /admin/config/varbase/varbase-media-header and select 'Landing page'
4) Add a landing page with video as VMH video
5) Check: /admin/structure/types/manage/landing_page/fields has field Main media (field_media)
6) Add a view of content: landing page and display unformatted list of fields:
6 a) Try to add the field Main media (field_media) and it is listed: "Appears in: landing_page. Also known as: Content: Main media"

I'll try and create a patch with this. I wonder if the field can be added to a content type is a 'raw' way with \Drupal\field\Entity\FieldConfig::create and then the config still modified with the yml file so we have the best of both worlds?

🐛 Bug report
Status

Closed: outdated

Version

9.0

Component

Code

Created by

🇦🇺Australia rjzaar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024