I'm using version 7.x-2.10 of CDN module and version 7.x-1.18 of CKEditor module. These are the steps to replicate the issue:
1) Create a new content.
2) In the body field, click on the button "Add media". A pop up will appear.
3) Upload a new image. Before submitting the image, you'll see a screen like in the screenshot, but you won't see the image. If you right click on it and open image in a new tab, you'll see that the cdn url has been generated. If you check in the files folder, the image has been uploaded.

I've created a provisional patch to not use cdn on ckeditor images, but probably there's a better approach. My patch excludes admin paths from cdn and check that the file exists before overriding the url.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guardiola86 created an issue. See original summary.

Wim Leers’s picture

Category: Bug report » Support request
Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Did you recently update modules? I'm very very surprised that this bug would only be discovered now, more than a year after the last CDN module release and more than a year after the latest CKEditor module release.

OTOH, it looks like you're using the Media Browser module? It sounds like it's not working in there?

guardiola86’s picture

The modules were updated some time ago, but the CDN was disabled because of that issue with CKEditor.
The site is using CKEditor Media Browser and Media CKEditor.

Wim Leers’s picture

Title: Issue when uploading an image in wysiwyg editor. » Uploading an image in CKEditor Media Browser breaks when using the CDN module because file_create_url() is not used
Project: CDN » CKEditor Media Browser
Version: 7.x-2.10 » 7.x-2.x-dev
Category: Support request » Bug report
Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Active

Ok. So the problem only manifests when using https://www.drupal.org/project/ckeditor_media.

I just looked at https://cgit.drupalcode.org/ckeditor_media/tree/plugins/mediaBrowser/plu..., and it has this:

        // There is probably a better way of getting the url for the file
        // but media returns the object with an absolute url and the uri.
        // We don't have access to file_create_url in javascript so we can't
        // use that. For now, just remove the server name from the absolute
        // url to get the relative. FIX THIS!!!
        var fileUrl = mediaFiles[0].url.replace(location.origin, '');

This is the root cause. Not the CDN module. Moving to the right issue queue :)

guardiola86’s picture

Ah ok. Thanks for looking into it :)

guardiola86’s picture

Project: CKEditor Media Browser » Media CKEditor
guardiola86’s picture

I've updated the project, I've noticed it's actually happening in media_ckeditor module.

guardiola86’s picture

Project: Media CKEditor » CKEditor Media Browser
guardiola86’s picture

Reverting it, it's actually in CKEditor Media Browser, having two modules with a similar name is confusing.

guardiola86’s picture

I wonder though, if it wouldn't be easy to add this to the function cdn_file_url_alter:

// Do not use cdn on admin pages.
  if (path_is_admin(current_path())) {
    return;
  }

CKEditor is especially problematic and I don't really see the point of using CDN in admin pages.

guardiola86’s picture

I'm still struggling with this. What I've noticed is, that even though the cdn path to the image is correct, the image doesn't exist in the cdn. Any idea why is this happening? Thanks.