Loading drowl_media.module +6 −3 Original line number Diff line number Diff line <?php use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Url; /** * @file * DROWL media module file. Loading Loading @@ -87,7 +90,7 @@ function drowl_media_field_widget_form_alter(&$element, FormStateInterface $form /** * Implements hook_ENTITY_TYPE_view(). */ function drowl_media_media_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { function drowl_media_media_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { // Attach the media library to all media previews in the admin route if (!empty($build) && !empty($view_mode) && $view_mode == 'media_library') { $build['#attached']['library'][] = 'drowl_media/admin_media_library'; Loading @@ -101,7 +104,7 @@ function drowl_media_media_view(array &$build, \Drupal\Core\Entity\EntityInterfa * widget button. This is a *workaround* to provide a link for slideshow creation * as "Slideshow" is a custom media source, which doesn't provide a create itself. */ function drowl_media_field_widget_media_library_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { function drowl_media_field_widget_media_library_widget_form_alter(&$element, FormStateInterface $form_state, $context) { if (!empty($element['#target_bundles']) && in_array("slideshow", $element['#target_bundles'])) { // Change the regular "Add"-label, so its clear to the user that this means // "Reference to existing Slideshows" Loading @@ -110,7 +113,7 @@ function drowl_media_field_widget_media_library_widget_form_alter(&$element, \Dr $element['#field_suffix']['empty_selection'] = [ '#type' => 'link', '#title' => t('Create new Slideshow'), '#url' => \Drupal\Core\Url::fromRoute('entity.media.add_form', ['media_type' => 'slideshow']), '#url' => Url::fromRoute('entity.media.add_form', ['media_type' => 'slideshow']), '#attributes' => [ 'target' => '_blank', 'class' => ['button', 'primary'], Loading Loading
drowl_media.module +6 −3 Original line number Diff line number Diff line <?php use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Url; /** * @file * DROWL media module file. Loading Loading @@ -87,7 +90,7 @@ function drowl_media_field_widget_form_alter(&$element, FormStateInterface $form /** * Implements hook_ENTITY_TYPE_view(). */ function drowl_media_media_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { function drowl_media_media_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { // Attach the media library to all media previews in the admin route if (!empty($build) && !empty($view_mode) && $view_mode == 'media_library') { $build['#attached']['library'][] = 'drowl_media/admin_media_library'; Loading @@ -101,7 +104,7 @@ function drowl_media_media_view(array &$build, \Drupal\Core\Entity\EntityInterfa * widget button. This is a *workaround* to provide a link for slideshow creation * as "Slideshow" is a custom media source, which doesn't provide a create itself. */ function drowl_media_field_widget_media_library_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { function drowl_media_field_widget_media_library_widget_form_alter(&$element, FormStateInterface $form_state, $context) { if (!empty($element['#target_bundles']) && in_array("slideshow", $element['#target_bundles'])) { // Change the regular "Add"-label, so its clear to the user that this means // "Reference to existing Slideshows" Loading @@ -110,7 +113,7 @@ function drowl_media_field_widget_media_library_widget_form_alter(&$element, \Dr $element['#field_suffix']['empty_selection'] = [ '#type' => 'link', '#title' => t('Create new Slideshow'), '#url' => \Drupal\Core\Url::fromRoute('entity.media.add_form', ['media_type' => 'slideshow']), '#url' => Url::fromRoute('entity.media.add_form', ['media_type' => 'slideshow']), '#attributes' => [ 'target' => '_blank', 'class' => ['button', 'primary'], Loading