Problem/Motivation
For media library model, if we have a content type contains media field and this media field is limited to add only one image for this content type. If the user select the image from the media library and then swipe into the next page on the library, then the user can add more than one image.
Steps to reproduce
- Navigate into any content type has a media and limited to add only one image as site admin user.
- Click on "media" tab
- Try to add any image from the library, and then move into the next page in the library and try to add more images.
- Observe that user is still able to add more media from the next pages.
Proposed resolution
The user should not be able to add media from the next page in the media library if he reached the limit.
My findings are:
#3059955: It is possible to overflow the number of items allowed in Media Library
More reported issues with videos and images in the duplicate issue
#3092536: Possible to select multiple images in a media field where only 1 value is acceptedQuick fix
The maintainer for the Media Library module Adam G-H (phenaproxima) is most likely will commit this fix into the next release of Drupal core.
#3059955: It is possible to overflow the number of items allowed in Media LibraryWe could have the patch fix in Varbase Core before it been committed and released with Drupal Core.
Remaining tasks
- ✅ File an issue about this project
- ✅ Add the 3059955-107.patch to fix drupal-9.2.x
- ✅ Testing to ensure no regression
- ➖ Automated unit/functional testing coverage
- ➖ Developer Documentation support on feature change/addition
- ➖ User Guide Documentation support on feature change/addition
- ✅ Code review from 1 Varbase core team member
- ✅ Full testing and approval
- ✅ Credit contributors
- ✅ Review with the product owner
- ✅ Release varbase-9.0.3, varbase_core-9.0.10
User interface changes
Having a message and a blocker of insert action is good

It's working well
After the fix:
Warning message
There are currently 2 items selected. The maximum number of items for the field is 1. Please remove 1 item from the selection.
1 was selected then on the upload of new image media file

Very good as not able to insert selected if they are out of the limit
After unchanging the extra old selected media item
Then we are able to insert
API changes
- N/A
Data model changes
- N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | save and insert.png | 95.6 KB | mookum |
| #32 | add-images.png | 518.46 KB | mookum |
| #32 | Schermafbeelding 2023-06-21 om 09.10.43.png | 48.78 KB | mookum |
Issue fork varbase_core-3246182
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:

Comments
Comment #2
rajab natshahThank you, for reporting
My findings are:
#3059955: It is possible to overflow the number of items allowed in Media Library
More reported issues with videos and images
#3092536: Possible to select multiple images in a media field where only 1 value is accepted
Quick fix
The maintainer for the Media Library module Adam G-H (phenaproxima) is most likely will commit this fix into the next release of Drupal core.
#3059955: It is possible to overflow the number of items allowed in Media Library
We could have a patch fix in Varbase Core before it been committed and released with Drupal Core.
So I'm going to use the patch from #3059955: It is possible to overflow the number of items allowed in Media Library
Not for the other issue.
Comment #3
rajab natshahComment #5
rajab natshahComment #6
rajab natshahComment #7
rajab natshahComment #8
rajab natshahComment #9
rajab natshahComment #10
Delana_Alkurdi commentedComment #11
Delana_Alkurdi commentedComment #12
rajab natshahComment #13
rajab natshahHaving a message and a blocker of insert action is good

Comment #14
rajab natshahComment #15
rajab natshahComment #16
rajab natshahComment #17
rajab natshahComment #18
rajab natshahComment #19
rajab natshahComment #20
rajab natshahComment #22
rajab natshahComment #23
rajab natshahSwitched back to ✅ Add the 3059955-107.patch to fix drupal-9.2.x
Some logic and code are changed in drupal-9.3.x .. the 760.patch was made to fix drupal-9.3.x not drupal-9.2.x
Comment #25
rajab natshahComment #26
rajab natshahComment #27
rajab natshahComment #28
rajab natshahComment #30
rajab natshahComment #31
rajab natshahComment #32
mookum commentedThis issue still persist when:
Drupal version: 9.5.9
Edit: Patch above do resolve this issue excuse me!