Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294882

Upload via Media Library field widget does not take all upload validators in account

$
0
0

First of all great to have the possibility to create and upload new media elements directly in the media field widget.

I came across an issue regarding media image elements. If there is an upload validator specified for image resolution this is not going to be taken into account from the media library field widget. Actually media library field widget does only use upload validation for extensions and file size.

I see that since it is possible to have a media field with multiple media types, it could get difficult to include this upload validation for resolution correctly in such a case that you may have different media types allowed in one field. So maybe it is intentional that the image resolution validator is left out (but I could not find a hint about this actually).

But I feel this is kind of a bug or at least very annoying if you have specified image resolution validation on a media type and this is just not taken into account via the media library field widget. It actually allows to circumvent this restriction.

I provide a patch that will enforce resolution validation if applicable. This is maybe just a start for solving this issue, because it does not handle cases where you might have different image media types with different settings for image resolution. But at least for a single media type this seems to work correctly.

Possibly the best solution would be to have an intermediate dialog in the media upload modal to choose the type of media first (if there are multiple types allowed) and then go to the actual upload form with the validators taken from the media type chosen. But this seems a bit more complicated.

Moreover as far as I could see it is not possible to remove just the "Add media" button from the media library field widget, so to basically allow the creation only via media/add but not via Media library field widget and therefore enforce the restrictions regarding resolution (of course this could be done by form_alter, but not via UI - this is discused here https://www.drupal.org/project/drupal/issues/2993187).


Viewing all articles
Browse latest Browse all 294882

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>