File upload button in Media Library missing in rc-3

Created on 22 March 2023, over 1 year ago
Updated 20 July 2023, 11 months ago

When I just upgraded from 1.0-rc2 to 1.0-rc3, the button to upload an image normally at the top of the Media Library has disappeared. When I revert back to rc2 then it appears again.

RC3:

RC2:

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mpotter

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

Comments & Activities

  • Issue created by @mpotter
  • πŸ‡ΊπŸ‡ΈUnited States mpotter

    Inspecting the markup in rc3 I don't even see the file upload input element. Digging more into a comparison of the markup to see what has changed.

  • πŸ‡ΊπŸ‡ΈUnited States mpotter

    Looks like in the working rc2, it loads the template: core/themes/stable9/templates/content-edit/file-managed-file.html.twig but in the broken rc3 it loads the template: modules/contrib/gin_lb/templates/content-edit/file-managed-file--gin-lb.html.twig. So something wrong in the new template?

    Also, this is on Drupal core 9.5.5

  • πŸ‡ΊπŸ‡ΈUnited States mpotter

    Looks like the gin_lb template was taken from claro, so maybe Gin or gin_lb is just missing the preprocess for this?

  • πŸ‡¬πŸ‡§United Kingdom bmchugh

    Can confirm I'm getting this issue also.

  • πŸ‡ΊπŸ‡ΈUnited States jhedstrom Portland, OR
  • πŸ‡ΊπŸ‡ΈUnited States jessehs Taos, New Mexico

    This is happening for me from within Layout Builder, using an image upload button in a CKEditor field. This triggers a modal window with the missing upload widget button.

    I foud that the missing preprocess (mentioned above in comment #4) would normally be in claro.theme: `claro_preprocess_file_managed_file()`

    Adding that logic from Claro to my frontend theme fixes that particular issue, but I'm also seeing that there are other messed up parts of this modal/popup form. (Sorry to go on a tangent, but it might be related.)

    I'm seeing that the issue is that gin_lb.module identifies this route (editor.image_dialog) as one to alter in the theme_suggestions_alter, but does not also alter the form (adding `#gin_lb_form`) in the matching route. See the two functions:

    /**
     * Implements hook_theme_suggestions_alter().
     */
    function gin_lb_theme_suggestions_alter(
      array &$suggestions,
      array $variables,
      $hook
    ) {
      if (gin_lb_is_valid_theme() === FALSE) {
        return;
      }
      $add_suggestions = FALSE;
      $route_name = \Drupal::routeMatch()->getRouteName();
      if (
      in_array(
        $route_name,
        [
          'layout_builder.add_block',
          'layout_builder.choose_block',
          'layout_builder.choose_inline_block',
          'layout_builder.remove_section',
          'layout_builder.remove_block',
          'layout_builder.choose_section',
          'view.media_library.widget_table',
          'view.media_library.widget',
          'media_library.ui',
          'editor.media_dialog',
          'editor.link_dialog',
          'editor.image_dialog', // This is the messed up route in question for me.
        ]
      )
    
    function gin_lb_is_layout_builder_form_id($form_id, array $form) {
      if (gin_lb_is_valid_theme() === FALSE) {
        return FALSE;
      }
      $form_ids = [
        'layout_builder_add_block',
        'media_image_edit_form',
        'media_library_add_form_oembed',
        'media_library_add_form_upload',
        'layout_builder_add_block',
        'layout_builder_remove_block',
        'layout_builder_update_block',
        'layout_builder_block_move',
        'layout_builder_configure_section',
        'form-autocomplete',
        'editor_image_dialog', // I added this item to fix it.
      ];
      $form_id_contains = [
        'layout_builder_translate_form',
        'views_form_media_library_widget_',
      ];
    

    In my case, this inconsistent route was "editor.image_dialog" -- adding the corresponding form id "editor_image_dialog" fixed some display issues I was having on the form.

    To circle back around to the original bug, I think that perhaps the same `hook_theme_suggestions_alter` (to add the Claro templates) and `hook_form_alter` (to add `#gin_lb_form`) could be also used to load the preprocess logic from `claro_preprocess_image_widget`.

  • πŸ‡ΊπŸ‡ΈUnited States jessehs Taos, New Mexico

    This patch adds the preprocess logic from Claro and adds the editor_image_dialog form Id as described in my previous comment.

  • πŸ‡ΊπŸ‡ΈUnited States jessehs Taos, New Mexico

    This differs from the last patch in that the preprocess logic from Claro should only be applied if the theme is not Gin. Otherwise it exits from those functions.

  • πŸ‡©πŸ‡ͺGermany Hydra

    I had the same issue and tested every proposed solution - non of them really worked for my usecase. We are using gin_lb in combination with the frontend theme - which can be kinda solved with the patch in #9 - but it makes it really complicated if you want to style the media_library in frontend.

    I decided that the best fit for our usecase was to completely disable the media integration of gin_lb.

    In order to not confuse the patches, I added my solution to a PR in https://www.drupal.org/project/gin_lb/issues/3349627 πŸ› No option to add or delete managed file/image. Fixed which describes the same issue. So if you are searching for a solution to disable the whole media integration, this might be helpful for you.

  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    I encountered the same problem when adding Gin LB support to forms provided by the Section Library β†’ module in πŸ’¬ Layout Builder Lock, UI Styles Layout Builder and Section Library support Fixed .

    I manually added the Section Library support because both patches could not be applied simultaneously. I propose to sort alphabetically $form_ids and the list in gin_lb_theme_suggestions_alter().

    This show that in $form_ids, layout_builder_add_block is already listed twice.

    I will update my MR in the other issue.

  • Status changed to Needs review about 1 year ago
  • Status changed to Fixed about 1 year ago
  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    Thanks, I applied #9.

  • πŸ‡¬πŸ‡§United Kingdom lexsoft London

    The latest dev version does not fixes this issue. Applying the patch does for image medias but not for video files possible same for documents.

  • Status changed to Needs review about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom lexsoft London
  • πŸ‡¬πŸ‡§United Kingdom very_random_man

    #9 Works for me with images and remote videos.

  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    In the commit https://git.drupalcode.org/project/gin_lb/-/commit/50577e28d12b2342cb4a2..., it is missing the hooks introduced in patch from comment 9.

  • @grimreaper opened merge request.
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    I opened an MR with the missing part of the patch.

    And here is a patch file for easier Composer usage.

    Thanks for the review.

  • πŸ‡¬πŸ‡§United Kingdom very_random_man

    This is working for me with media fields but I've just noticed standard image fields are still missing for me when RC3 is installed.

  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    I am using the section_library module too on my website and with the patch, the image field is ok.

    Or do you mean image fields on content entity form?

  • πŸ‡¬πŸ‡§United Kingdom very_random_man

    It was missing for me anywhere i used a single image upload field rather than a media item field. Definitely users and content. I'm pretty sure it was on blocks too. I've downgraded now so I can't check again just at the moment.

  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    Thanks to @jessehs, @Grimreaper and @mpotter all the others to figure out the issue.

  • Status changed to Fixed about 1 year ago
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Tested ok on the last dev version. Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 12 months ago
  • πŸ‡¨πŸ‡΄Colombia angelgarciaco BogotΓ‘, Colombia

    Hey guys.. I can confirm that the issue was fixed using the rc4 ( ^1.0@RC ) This apply for any media type using Layout builder (Image, Document, etc). Thank you so much.

  • πŸ‡¦πŸ‡ΊAustralia elgandoz Canberra

    I can confirm this is happening again on a vanilla installation while editing content on the front end theme (Olivero).
    By uninstalling the module the file field displays again.
    Versions:

    1. gin 3.0.0-rc5
    2. gin_lb dev-1.0.x (d0376485)


Production build 0.69.0 2024