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

  1. Navigate into any content type has a media and limited to add only one image as site admin user.
  2. Click on "media" tab
  3. Try to add any image from the library, and then move into the next page in the library and try to add more images.
  4. 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 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 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
Media Library after the fix

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
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

After unchanging the extra old selected media item

API changes

  • N/A

Data model changes

  • N/A
Command icon 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

Delana_Alkurdi created an issue. See original summary.

rajab natshah’s picture

Title: [Media library] The user can add more than one image if he swipe to add them from the next page from the media library window. » Fix Media library from Drupal core on user can add more than one image if he swipe to add them from the next page from the media library window
Issue summary: View changes

Thank 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.

rajab natshah’s picture

  • RajabNatshah committed f51e262 on 9.0.x
    Issue #3246182 by Delana_Alkurdi: Fix Media library from Drupal core on...
rajab natshah’s picture

Assigned: Unassigned » rajab natshah
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Assigned: rajab natshah » mohammed j. razem
Status: Active » Needs review
Issue tags: +varbase-9.0.3, +varbase_core-9.0.9
rajab natshah’s picture

Issue summary: View changes
Issue tags: -varbase_core-9.0.9 +varbase_core-9.0.10
rajab natshah’s picture

Assigned: mohammed j. razem » Unassigned
Delana_Alkurdi’s picture

Delana_Alkurdi’s picture

rajab natshah’s picture

rajab natshah’s picture

Issue summary: View changes

Having a message and a blocker of insert action is good
Media Library after the fix

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
Status: Needs review » Fixed
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Assigned: Unassigned » rajab natshah
Status: Fixed » Active
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Assigned: rajab natshah » Unassigned
Status: Active » Fixed

  • RajabNatshah committed 0bfd05c on 9.0.x
    Issue #3246182: Fix Media library from Drupal core on user can add more...
rajab natshah’s picture

Assigned: Unassigned » rajab natshah
Status: Fixed » Active
rajab natshah’s picture

Issue summary: View changes

Switched 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

  • RajabNatshah committed b6f6b34 on 9.0.x
    Issue #3246182: Fix Media library from Drupal core on user can add more...
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Status: Active » Fixed
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Assigned: rajab natshah » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
mookum’s picture

StatusFileSize
new48.78 KB
new518.46 KB
new95.6 KB

This issue still persist when:

  • You add a media field restricted to upload 1 image, to a node.
  • Create a page , add one image and save this node
  • Go back edit this node, remove the image from the node: select some image + Add a new image from upload field: Save and insert.
  • 2 images are added, after that it fails to remove 1 image or save the node.

Drupal version: 9.5.9

Edit: Patch above do resolve this issue excuse me!