Problem/Motivation
It is not possible to embed multiple media items into CKEditor in one shot; you can only embed one at a time. This was deliberately done for multiple reasons. Here are a few extracted from comment #6:
- If we select multiple items to embed at once, what order should they be embedded in?
- How would people be able to re-order them?
- How would we make this accessible?
- How would we make it usable and intuitive to users?
Proposed resolution
Unclear, but if we want this feature, it's going to need answers to the above questions, plus any others that come up in the process of building this.
Remaining tasks
Figure out if we want this feature
Validate it with the UX team and accessibility maintainers
Create a patch with tests
Get subsystem maintainer sign-off
Get sign-off from the UX team
Get sign-off from the accessibility maintainers
Commit
User interface changes
TBD
API changes
TBD
Data model changes
Unlikely, but TBD
Release notes snippet
TBD
Issue fork drupal-3129235
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3129235-allow-embedding-multiple
changes, plain diff MR !432 /
changes, plain diff MR !13424 /
changes, plain diff MR !12633
Comments
Comment #2
joseph.olstadComment #3
cilefen commentedFeatures can go into 9.1.x.
Comment #4
OCTOGONE.dev commentedComment #5
hardik_patel_12 commentedEmbedding media with CKEditor is selecting only 1 media item , this because in core/modules/media_library/src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php file in getConfig(Editor $editor) function
media_library_remaining is hardcoded to 1 , i don't know this is intentionally hardcoded or not .
Suppose if user wants to upload multiple image then system will not gone allow, so instead of hardcoding to 1 we can set unlimited value for media_library_remaining so user can select images on the basis of their choice.
Comment #6
phenaproximaCKEditor was limited to one embed for an excellent reason: allowing multiple embeds at once introduces several UX- and accessibility-related complications. For example, what order should the items be inserted? If we want to allow people to re-order them (and we obviously should), how would that work, and would it make sense to users? Would it be accessible? If not, how would we make it accessible?
Allowing only one embed bypassed all of these issues, allowing us to deliver the basic feature on time in Drupal 8.8. I'm not saying we could never have the ability to embed multiple items at once, but we'd have to think it through very carefully first.
Comment #7
phenaproximaComment #8
aaronmchaleAdded issue summary template, actual content needs updated though.
Comment #9
aaronmchaleBetter title.
Comment #10
phjouI discovered the same issue.
I strongly disagree with the statement:
"selecting multiple media of different type doesn't make sense"
In my case I wanted to create my own ckeditor plugin based on the one from Media. It is to create a gallery and it is supposed to show images or videos.
Comment #11
phenaproximaThe problem is not selecting media of different types -- that bit makes perfect sense. The problems arise when trying to embed multiple media items, regardless of type, for some of the reasons I outlined in #6. I have updated the issue summary accordingly.
Comment #12
phenaproximaComment #14
jidrone commentedThis is my opinion regarding the concerns:
If we select multiple items to embed at once, what order should they be embedded in?
I think for most of the users it doesn't matter as long as they are able to reorder them.
How would people be able to re-order them?
Currently, the media items are already draggable in the CKEditor, maybe we can make the draggable icon more prominent and easier to click.
How would we make this accessible?
I think the previous point will resolve this
How would we make it usable and intuitive to users?
I think if the user can select as many items as they want, then if all of them are stacked when inserted on the editor it is intuitive.
Comment #16
jidrone commentedComment #17
benjifisherWe discussed this issue at the end of #3208186: Drupal Usability Meeting 2021-04-23. We agreed that this is a useful change.
As far as usability is concerned, the main thing we would like to see is an easier way to rearrange things in CKEditor. There is a "handle" with the hover text "Click and drag to move", but in my brief test it did not work. But fixing that is a problem for CKEditor and/or its integration with Drupal. That is not a blocker for this issue.
The plan is to make CKEditor 5 the default for Drupal as soon as we can (probably in Drupal 10). There is already a contrib module CKEditor 5. I think it would be interesting to see whether that helps with this issue.
Here is a screenshot showing the "handle":
Comment #19
sleopold commentedThe patch above lets you upload multiple media entities at once, but still only lets you insert one at a time. The following patch will let you upload and insert multiple. As mentioned above, the UI isn't great once they're in, but there is a handle to drag things around.
Comment #20
sleopold commentedComment #21
sleopold commentedComment #22
jidrone commentedHi @sleopold,
The fix including test is in the Merge Request.
Comment #24
4kant commentedThe patch in #21 works well for me.
Comment #25
ranjith_kumar_k_u commentedComment #28
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #30
mayurngondhkarReroll patch
Comment #31
mayurngondhkarhttps://www.drupal.org/project/drupal/issues/3129235#comment-15175457
Rerolled against drupal `9.5.x`
Comment #32
jopdebeeck commentedWe required this feature when upgrading to Drupal 10.1.2.
I rerolled the patch for use in drupal 10.1.x
Patch might not apply for 10.1.2 specifically. In that case, checkout the 10.1.2 core tag, apply the patch and if the hunk on
drupalMedia.js fails to apply, you can skip that and remake the patch after running yarn in the core folder:
cd core
yarn install
yarn build:ckeditor5
Comment #33
_utsavsharma commentedFixed failures in #32 for 10.1.x.
Comment #34
glenndw commentedThe previous patch had a problem when adding media.
Comment #35
4kant commented#34 doesn´t apply any more after update from drupal 10.1.4 to 10.1.5
Thanks!
Comment #36
jopdebeeck commented#35
Rerolled the patch for 10.1.5
Comment #37
vsujeetkumar commented@GlennDW Interdiff should be there in #34, It's help others to understand the changes you have done.
@jOpdebeeck diff required while we rerolling. Please check the doc.
Comment #38
glenndw commentedRerolled the patch for 10.2.3
Comment #39
jhandsta commented@vsujeetkumar Interdiffs on re-rolls are usually not really required, because only the patched context should be different on a re-roll and not the changes themselves.
That said, there were some issues with the last patch, so in this case an interdiff could indeed be useful :)
Comment #40
glenndw commentedRerolled the patch for 10.2.8
Comment #41
wannesdrAnd a reroll for Drupal version 10.3.5 as well.
Comment #42
loze commentedCan someone reroll this for 10.4.1 ?
Comment #43
mahdeAnd a reroll for Drupal version 10.4.4!
Comment #46
loze commentedCan someone roll it for 10.5?
Comment #48
mrinalini9 commentedPlease ignore #47 merge request.
Here is the patch rerolled for 10.5.x, please review it.
Thanks!
Comment #49
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #50
e0ipsoThis is the patch I am using in one of our Drupal installs running Drupal 10.4.7.Oops. I uploaded the wrong thing.
Comment #51
e0ipsoComment #54
loze commentedThe patch intended for 10.5 in #47 applies but did not work for me. Does someone have one?
I got this error
Comment #55
loze commentedAnyone?
Comment #57
jhandsta commentedThe previous patch (in #48) was missing the built JS, causing the error in #54.
Here is a re-roll for Drupal 11.3.3.
Comment #58
glenndw commentedRe-roll for Drupal 11.3.7