linkit_media_library.opener.editor must be an instance of Drupal\media_library\MediaLibraryOpenerInterface

Created on 15 July 2024, 3 months ago
Updated 17 September 2024, about 1 month ago

Problem/Motivation

Linkit media library button doesn't open in CKEditor 5

Steps to reproduce

Install Linkit Media Library with Drupal 10.3. Edit content with CKEditor 5, link a text to a media, media library doesn't open

Proposed resolution

Missing autoconfigure in service.

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada mmaranao Calgary, AB

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

Comments & Activities

  • Issue created by @mmaranao
  • πŸ‡¨πŸ‡¦Canada mmaranao Calgary, AB

    Fix by adding autoconfigure on service

  • I was able to apply this patch on 10.3.1 and the media library button now opens the dialog.

    After that I can search for media just fine and it returns from the media ui with the media id in the dialog. Looks good so far but if I click the green check, it does not insert the link and now the field with the media id in it gets garbled. If I click into that field, I get media not found.

  • πŸ‡¨πŸ‡¦Canada Sseto

    I'm getting the same thing as glenshewchuck, but I figured out how to still make it work. Once you selected your media in the library, you click on the Link Url field and you will get a popup of the file you inserted earlier. Click on it and you'll be able to click the green check mark.

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

    I'm experiencing this same error with CkEditor 4.

    Drupal Core 10.3.2
    Linkit 6.1.4
    Linkit Media Library 1.0.3

    Full error
    RuntimeException: linkit_media_library.opener.editor must be an instance of Drupal\media_library\MediaLibraryOpenerInterface in Drupal\media_library\OpenerResolver->get() (line 46 of /web/core/modules/media_library/src/OpenerResolver.php).

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

    According to this core change record β†’ Drupal 10.3 and above, media library opener services must be explicitly tagged with the media_library.opener tag.

    Tried and worked for us. linkit_media_library.services.yml should read:

    services:
      linkit_media_library.opener.editor:
        class: Drupal\linkit_media_library\LinkitMediaLibraryEditorOpener
        arguments: ['@entity_type.manager']
        tags:
          - { name: media_library.opener }
  • πŸ‡ΊπŸ‡ΈUnited States Kristi_06

    Patch for anyone who needs it.

  • Status changed to RTBC about 1 month ago
  • πŸ‡ΊπŸ‡ΈUnited States a-fro

    Patch #7 works for me. Given the change record linked to in #6, this seems like a non-controversial fix and could be merged and released.

Production build 0.71.5 2024