1

I can't upload images with CkEditor 5 in my Drupal 10.1.6 website (which runs on PHP 8.2); all the other features work fine.

Can't upload image Ckeditor5

In my recent upgrade of Drupal, I switched directly from Drupal 9.4 to Drupal 10.1.6. I followed Upgrading to CKEditor 5.

I've seen ckeditor5 upload image MethodNotAllowedException where they talk about this problem. Spokje's comment says that issue is a duplicate of AccessAwareRouter does not respect HTTP method which has been already fixed on September 18, 2023. So normally the issue should not re-appear, shouldn't it?

I also already seen Why is MethodNotAllowedException thrown when an image is uploaded with CKEditor 5? but I can't find the user settings where I could change the language to default. In my website, we don't use this field on user. We just have first name, last name, email, password, and state.

I've enabled Account administration pages on /admin/config/regional/language/detection (Detection and selection).

In my admin profile, I can just update my mail or the password.

I can't find where the problem is. I have the Editor Advanced Link module installed, but that is compatible with Drupal 10 and CkEditor 5. (I've tested it.)

Can you help me please? I do not see errors in the Drupal log.

5
  • Are there browser console errors?
    – mona lisa
    Commented Nov 28, 2023 at 16:25
  • @cilefen, No errors in console when I try to upload the image, but errors when I am on the page : [Deprecation] The keyword 'push-button' specified to an 'appearance' property is not standardized. It will be removed in the future. and Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at addEventListener at edit?destination=/admin/news:1444:26124 at edit?destination=/admin/news:1444:19767 at xhr.onreadystatechange (edit?destination=/admin/news:1444:7693). Here is the part of the JS code
    – PtitBreton
    Commented Nov 28, 2023 at 16:49
  • The "Can't upload image" error is set in drupalimageuploadadapter.js and it shown in the error handler to a JavaScript XMLHttpRequest. Are you certain there are no server-side errors logged? What is indicated on the network tab of the browser developer tools?
    – mona lisa
    Commented Nov 28, 2023 at 18:26
  • Thanks for your answers. I have a [prnt.sc/aUz4MItDYR_V](status code 200) on my image JPEG and on the link my-site/ckeditor5/upload-image/… I have a [prnt.sc/R6Fr9a7xDqVU](302 found status code). I don't know if I search in right place
    – PtitBreton
    Commented Nov 29, 2023 at 8:58
  • Ok my bad, I found the error, we had restricted access for the admin on our website with a function [prnt.sc/oeYshbs0B0zu]("isAllowedPath") on a AdminEventSuscriber. So we were redirected automatically to home admin (people list) page. Sorry for that and thnak you very much for your help !
    – PtitBreton
    Commented Nov 29, 2023 at 9:26

1 Answer 1

0

I found the error, I had restricted access for the admin on the website with a function "isAllowedPath" on a AdminEventSuscriber. So we were redirected automatically to home admin (people list) page.

   * Restrict the access to some paths for the admin.
   *
   * @param string $path
   *
   * @return bool
   */
  protected static function isAllowedPath(string $path): bool {
    return str_starts_with($path, '/admin') ||
      str_starts_with($path, '/editor') ||
      str_starts_with($path, '/entity_reference_autocomplete') ||
      str_starts_with($path, '/ckeditor5') || // Fix here --> Adding Ckeditor5 path
      $path === '/user/{user}/masquerade' ||
      $path === '/unmasquerade' ||
      $path === '/dqe/check' ||
      $path === '/views/ajax' ||
      $path === '/navigate/as/{user}' ||
      $path === '/user/logout' ||
      $path === '/system/files/{scheme}' ||
      preg_match('#^/sites/[a-z]{3}/files/styles/{image_style}/{scheme}#i', $path) === 1 ||
      preg_match('#^/editor/dialog/image/{editor}#i', $path) === 1 ||
      preg_match('#^/profiler#i', $path) === 1 ||
      preg_match('#^/cron#i', $path) === 1 ||
      preg_match('#^/views-bulk-operations#i', $path) === 1 ||
      preg_match('#^/batch#i', $path) === 1;
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.