I've been trying to limit a media field to limit the amount of uploaded images per field. Found something with https://www.drupal.org/project/upload_maxfiles but no Drupal 10 equivalent. I would like to limit the number of uploaded images based on roles. For example, a student role can upload only 1 image to a field. Manager can upload 5 images.
I was able to use hooks to edit the cardinality and now need to limit the amount to files associated with the field but keep seeing: 'Unlimited number of files can be uploaded to this field.' How can I limit the max uploaded files associated to one field by using hooks?
I'm currently using the media library widget.
I have seen D6 an D7 solutions but not for D10: