X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fmedia%2Fmedia.module;fp=web%2Fmodules%2Fcontrib%2Fmedia%2Fmedia.module;h=66e50cee20942205fc4e56868d0e501ec28f634b;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/media/media.module b/web/modules/contrib/media/media.module new file mode 100644 index 000000000..66e50cee2 --- /dev/null +++ b/web/modules/contrib/media/media.module @@ -0,0 +1,83 @@ +' . t('About') . ''; + $output .= '

' . t('Media module for Drupal 8') . '

'; + return $output; + + default: + } +} + +/** + * Implements hook_form_alter(). + */ +function media_form_alter(&$form, FormStateInterface &$form_state) { + if ($form['#form_id'] == 'entity_browser_media_library_form') { + // Style the submit button. + $form['actions']['submit']['#attributes']['class'][] = 'button--primary'; + $form['actions']['submit']['#attributes']['class'][] = 'entity-browser-modal-target'; + } + // Remove the Gallery option from create gallery view's bundle filters. + if ($form['#id'] == 'views-exposed-form-media-library-gallery-media-select-modal' || $form['#id'] == 'views-exposed-form-media-library-gallery-user-media-select-modal') { + unset($form['bundle_1']['#options']['gallery']); + } + if ($form['#form_id'] == 'media_gallery_form') { + $form['#attached']['library'][] = 'media/view'; + } +} + +/** + * Implements hook_views_pre_render(). + * + * Adds the media.view library to the media views. + */ +function media_views_pre_render(ViewExecutable $view) { + if (isset($view) && ($view->storage->id() == 'media_library' || $view->storage->id() == 'global_media_library')) { + $view->element['#attached']['library'][] = 'media/view'; + } +} + +/** + * Implements hook_menu_local_actions_alter(). + * + * Adds the add media button from media_entity on library pages. + */ +function media_menu_local_actions_alter(&$local_actions) { + $local_actions['media.add']['appears_on'][] = 'view.media_library.user_media_library'; + $local_actions['media.add']['appears_on'][] = 'view.media_library.global_media_library_page'; +} + +/** + * Implements hook_entity_type_alter(). + */ +function media_entity_type_alter(array &$entity_types) { + $field_name = \Drupal::config('media_entity.bundle.gallery')->get('type_configuration.source_field'); + $entity_types['media']->addConstraint('GalleryMediaBundle', array('sourceFieldName' => $field_name)); +} + +/** + * Implements hook_menu_links_discovered_alter(). + */ +function media_menu_links_discovered_alter(&$links) { + // Media entity module provides a default view which we disable. Since it also + // provides a link entry for it we need to update the route there to point to + // the media library we provide. + $links['entity.media.collection']['route_name'] = 'view.media_library.global_media_library_page'; +}