Image minimum and maximum resolutions should be configurable per field instance (for fields of Reference type Media with Media type Image) and these should be honored when uploading new images or selecting existing ones from the media library

Created on 28 November 2018, about 6 years ago
Updated 28 May 2024, 7 months ago

In modern Drupal (8.4/9/10), Media in core has no option to set minimum / maximum resolutions on media items that can be selected.

This is problematic because an image field meant to show full-screen (2,000 pixels+) might have been uploaded as only a 200 pixels across. (Allowing this smaller size to be uploaded and used is all right in other contextsโ€” other fields.) Rather than splitting media types and media libraries, it's better to filter the media library for the images which fit minimum resolution requirements for a given field, or trigger a validation when a too-small image is selected.

For fields of Reference type: Media
with Media type: Image
The image minimum resolutions should be configurable (per field instance if feasible, if not per field is good too)

The minimum width and minimum height should be honored:

  • when uploading new images, or
  • when selecting existing images from the media library
โœจ Feature request
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Mediaย  โ†’

Last updated 3 days ago

Created by

๐Ÿ‡ฉ๐Ÿ‡ฐDenmark supermoos

Live updates comments and jobs are added and updated live.
  • Field UX

    Usability improvements related to the Field UI

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mlncn Minneapolis, MN, USA

    Updated issue summary. I dropped the part about configuring maximum resolutions per field because i don't see the use case; if it is a server space limitation that would be sitewide, no?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Kasey_MK

    @mlncn being able to configure the maximum resolution is absolutely critical to the problem we were experiencing, where people were uploading images that were way too big for Drupal to process (3840 pixels in either dimension seems to be the breakpoint). The uploads would appear to finish, but none of the image styles could be processed from it.

    Patch #24 solved that problem for us, allowing people to upload images of any size via any field which would then be properly resized and processed.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Kasey_MK
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jvogt Seattle, WA

    Thanks, Kasey. Setting max resolution is critical for us as well. It's about making the images fit for purpose. We want to prevent users from bogging down the site storage with 5000px wide images that will only ever be used as a 100px wide thumbnail.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rajeevgole

    Does the patch also take care of the #2nd(when selecting existing images from the media library) use case mentioned in the issue description?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jvogt Seattle, WA

    @rajeevgole: no I don't believe it does. It seems to alter only the Media library upload form.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jvogt Seattle, WA

    I'm not sure the patches in #24/26 address the original issue. I think they are (and I am) looking for a way to control the image resolution from a Media reference field, with Image media as an allowed type, rather than from the Image field within a Media type. I realize this means two places where min/max can be configured, but I'm really trying to avoid creating a separate Media type for images where I want to control the resolution at time of upload.

    It's possible that this just isn't how Media entities are intended to be used in Drupal 8/9/10+, but if that's the case, I'm struggling to find any documentation to that effect or a good workaround for my use case. The entity_browser โ†’ module provides the "Upload images as media items" widget that allows you to specify an upload location, which overrides the selected Media type's location, so maybe that's a more appropriate place for this kind of feature.

  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia bhanu951

    Rerolled patch from #26 against 11.x branch.

  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia bhanu951
  • Pipeline finished with Failed
    7 months ago
    Total: 557s
    #179018
  • Pipeline finished with Failed
    7 months ago
    Total: 663s
    #179907
  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Have not tested

    But issue summary should be updated to match standard template please

    Sounds like something that could use some test coverage also.

    Thanks.

Production build 0.71.5 2024