Problem/Motivation
(for quick setup, Install Umami 8.8.x)
Steps to reproduce -
1. View an article, and click on quickedit on top-right corner
2. Place the cursor anywhere in the body, and click on add-media icon
3. Select the image from media_library
4. Click on "Insert Selected"
Result -
Image is not added, and there's an error in the console
plugin.js?t=0:148 Uncaught TypeError: Cannot read property 'getAttribute' of null
at d.upcast (plugin.js?t=0:148)
at Array.<anonymous> (<anonymous>:29:162)
at iterator (<anonymous>:874:440)
at window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.htmlParser.element.forEach (<anonymous>:294:397)
at window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.htmlParser.fragment.forEach (<anonymous>:294:498)
at e.<anonymous> (<anonymous>:887:94)
at e.g (<anonymous>:10:70)
at e.<anonymous> (<anonymous>:11:433)
at e.window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.editor.CKEDITOR.editor.fire (<anonymous>:13:97)
at CKEDITOR.htmlDataProcessor.toHtml (<anonymous>:315:222)https://www.youtube.com/watch?v=nOCuBPgNink
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | 3092593_27.patch | 1.69 KB | zhawkins |
| #25 | Screenshot from 2022-08-19 16-35-50.png | 110.33 KB | jatingupta40 |
| #25 | Screenshot from 2022-08-19 16-45-15.png | 158.51 KB | jatingupta40 |
| #24 | 3092593_24.patch | 1.66 KB | aarti zikre |
| #21 | 3092593_21.patch | 1.66 KB | aarti zikre |
Comments
Comment #3
tuan.hmt commentedI got the same with Drupal 8.9.1, when I clicked in the CKEditor area to edit my content, the medias was disappeared
The error related to the missing the attribute named "data-media-embed-host-entity-langcode":
var hostEntityLangcode = document.getElementById(editor.name).getAttribute('data-media-embed-host-entity-langcode');Comment #4
phenaproximaThis could use a test, at the very least. :)
Comment #5
solantoast commentedI added a patch that checks the element exists before getting any attributes from it. I was then able to add images to WYSIWYG fields using quick edit without errors.
Comment #6
manojithape commentedVerified and tested patch#5 on the drupal 8.9.x version. Patch applied successfully and one observation is there...
Testing Steps:
8. Now apply given patch and again follow above steps and verify that user is able to upload media file without any error message on console.
Testing Results:
After applying the patch user is able to upload the selected image successfully and also below error not displayed on the console.
Observation:
The user is able to upload the image successfully but the below error displayed on the console.
Comment #7
solantoast commented@manojithape - I was able to get rid of that error with additional preprocessing as explained in another issue's comment: https://www.drupal.org/project/drupal/issues/3101267#comment-13711587
Comment #8
manojithape commented@solantoast: Ok, Then we can move this ticket to RTBC by referring comments #6 and #7.
Comment #9
gauravvvv commented@manojithape, Patch #5, is failing the Drupal CI. Please don't make RTBC when a patch is failing Drupal CI.
Re-rolled patch #5. attached interdiff for the same.
Please review.
Comment #10
gauravvvv commentedComment #11
boby_ui commented+1 I can confirm that patching the #9 version fixed the issue
Comment #12
chetanbharambe commentedHi Community Members,
I have tested this issue on the 8.9.x-dev version (Umami Site)
Everything looks good to me and I don't see any errors in the console.
Testing Steps:
# Install drupal 8.9.x umami site
# Create Article Content type
# View an article and click on quick-edit on the top-right corner
# Place the cursor anywhere in the body and click on the add-media icon
# Select the image from media_library
# Click on "Insert Selected"
Here, Attaching the video and screenshots for the same which looks good to me.
Can be a move to +1 RTBC.
Comment #13
abhijith s commentedApplied patch #9 and media can be added via quick-edit after applying this patch.
Before patch:

After patch:

RTBC +1
Comment #16
zhawkins commentedRerolled patch.
Comment #17
ranjith_kumar_k_u commentedFixed CS error.
Comment #18
Akash Kadam commented#17 Patch applied successfully and media can be added via quick-edit after applying this patch.
For reference added Before Patch and After Patch Screenshots
Comment #20
aarti zikre commented#17 applied successfully.
Testing steps:
* Install new instance of drupal 9.4.
* Enable media and media library modules.
* Go to /admin/config/content/formats/manage/basic_html?destination=/admin/config/content/formats and drag the "Insert from Media Library" button into the CKEditor toolbar. Enable the "Embed media" filter, and click "Save configuration".
* Go to your artical click on quick edit.
* In body try to add media.
Problem:
Image is not added, and there's an error in the console
After Patch:
Problem Got resolve we can successfully add the media from quick edit.
SS for reference:
Before patch With error:

After Patch:

Test result Pass
Comment #21
aarti zikre commentedRe-rolling patch for Drupal 10.
Confirming this same issue happens in Drupal 10.
Comment #22
aarti zikre commentedPlease review this
Comment #23
jatingupta40 commentedI will review the patch.
Comment #24
aarti zikre commentedResolve custom command
Comment #25
jatingupta40 commentedThe patch #24 applied cleanly.
Tried the working/functionality refering steps in #20 and the functionality works absolutely fine.
Before applying the patch :
The image didn't add and showed an error in the console.
After applying the patch :
The image got applied and didn't show any error on the console.
Screenshot for before and after patch applied.
Moving to RTBC.
Thanks.
Comment #26
alexpottWe still need tests for this change as @phenaproxima asked for in #4. Also 10.x javascript no longer has .es6.js files. Plus quickedit does not exist there (but it is in contrib).
Comment #27
zhawkins commentedRerolled patch against 9.5.3.
Comment #28
lauriiiMoving to the Quick Edit issue queue since the module has been removed from core.