Media type image resolution restrictions are not enforced

Created on 19 September 2023, over 1 year ago
Updated 3 October 2023, about 1 year ago

Problem/Motivation

When using a Media Type (entity reference) as a Site Setting field, the referenced Media Type Image's minimum and maximum resolution settings are ignored. This allows the uploading of images that are smaller or greater than the resolution settings.

Steps to reproduce

Create a media type that contains an image field.
Set a minimum and/or maximum resolution size on the image field.
Configure a site setting that references the media type created above.
Create the site setting and upload an image that is outside of the minimum/maximum resolution settings you previously configured. It will allow that image to be uploaded.

Proposed resolution

Apply the same restrictions set in the Media Type when creating the Site Setting.

Potential Workaround

Instead of uploading the image via Site Settings, first upload the image under /media/add, then reference that image in the site setting.
This way the restrictions are enforced by Media Module before creating the Site Setting.

🐛 Bug report
Status

Closed: duplicate

Version

1.20

Component

Code

Created by

🇨🇦Canada djac

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @djac
  • Status changed to Postponed: needs info about 1 year ago
  • 🇬🇧United Kingdom scott_euser

    I don't think we make any modifications to the way the form field widgets work at all. Would it not be the same issue then if you add a media field to eg a Taxonomy Term? Possible an issue for Core if so rather than this module?

  • Status changed to Closed: duplicate about 1 year ago
  • 🇨🇦Canada djac

    It seems uploading a tiny image is allowed when using taxonomy that references a media type containing an image field with minimum resolution restrictions. So the taxonomy behavior seems similar to the site settings behavior and the image resolution min/max are not enforced.

    @scott_euser looks like you're right, this is looking like a core/media issue and not due to site_settings.
    Looks like this can be related to https://www.drupal.org/project/drupal/issues/3226629 🐛 Media Library field widget not enforcing image limits Active

Production build 0.71.5 2024