Closed (fixed)
Project:
D7 Media
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
19 Jul 2011 at 21:24 UTC
Updated:
15 May 2019 at 12:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
wmostrey commentedI created a related issue: #1226992: Media file selector widget ignores maximum filesize
Comment #2
dave reidI think this is closely enough related to #1226992: Media file selector widget ignores maximum filesize that we don't need two issues for it.
Comment #3
effulgentsia commentedIf #1223252: Media widget on filefield ignores "Allowed file extensions" filefield setting is a stable release blocker, then I think this should be too, so tagging.
Comment #4
dave reidYep, agreed. I missed adding the tag here.
Comment #5
dave reidComment #6
dave reidComment #7
idflood commentedNot sure if it's the correct way of doing this, but here is a copy/paste of 2 posts I made on a duplicate (#1140434: Size limits and other settings like in FileField).
possibly related or even duplicates:
Here are some initial observations:
So, for uploaded files I could imagine something as simple as:
But how would it be possible to access this $settings from media_add_upload() ? If I understand correctly we need to first pass these settings to media_media_browser_plugin_view() and then to the forms. Is that right? Any other solution?
Comment #8
dave reidI mistitled this issue. Apologies.
Comment #9
idflood commentedI've looked a little more in media code and found the media_get_browser_params() method. With this method it becomes easy to get the field instance settings in media_add_upload.
So here is a first patch which make media use the field instance settings when possible. It's already working relatively well on my tests but the patch isn't complete. I've applied the field instance settings after the media settings. So whenever you define a field instance setting it will override the similar media settings. This should be ok with min/max_resolution but what about file_extension?
Comment #10
wmostrey commentedThe patch in #9 also applies cleanly to 7.x-1.0-beta5 and it works as advertised. I tested it with min/max resolution and file extension.
Comment #11
idflood commentedI've found an issue where the generic file widget setting for file extension was always used. So I changed this specific setting to be used only if there is no media "type" enabled (audio/image/video/other).
There is also an added condition on "description_field" setting but I don't know what to do with it yet. I've also tried to implement the "file_directory" setting but finally commented the first try (in media_add_upload_submit()).
Comment #12
michaelfavia commentedApplied patch in #11 to no effect. I just want to make sure i am reading this issue correctly: Image fields that use the media widget for their selector SHOULD respect the max/min/alt/title settings on the content type settings.
It is successfully going into the upload step and transcribing the "$field_settings" to "$validators".
As i step through it in the debugger though it seems to never go through the imagefield validation checks only the file.inc ones.
Comment #13
idflood commentedThe patch isn't complete now and will not work for alt/title. There is 4 things implemented in it: max_resolution, min_resolution, file_extensions and max_filesize.
It should work for "file" or "image" fields with the "media selector" widget. In the field settings you can specifiy the settings discussed above. There is a special case for "file_extensions". This settings override the media "type" setting only if no media are checked (video/image/audio/other).
Here is a reroll of the last patch only fixing 3 trailing spaces.
Comment #14
dave reidComment #15
dave reidShrinking scope.
Comment #16
dave reidComment #17
dave reidComment #19
dave reidComment #20
dave reidComment #21
dave reidCommitted #19 to Git!
http://drupalcode.org/project/media.git/commit/195e217
http://drupalcode.org/project/media.git/commit/35fa08e
Comment #22
Wappie08 commentedMaybe a dumb question but where exactly can I set the max file size for my media (gallery) images ??
Greetings Wappie
Comment #24
Rob_Feature commentedReopening this to get some clarity (I realize it's old...sorry):
If I leave the setting blank for filesize (in the filefield), it SHOULD default to the maximum, correct? I'm not seeing this behavior.
If I leave the max size blank, it says `1000 bytes' as opposed to my php max (which is listed as 128MB).
If I put in 128MB manually, it works, but if I leave it empty, it does not.
Anyone else?
Comment #25
dave reid@Rob_Feature: The logic for the max upload size is the following:
I'd check what your media variable is set to.
Comment #26
dave reidIf this needs to be adjusted, please file a new bug report.
Comment #27
patrick.thurmond@gmail.comWas this ever supposed to be applied to the 1.x branch? I am using 1.4 and seeing this problem there and the 1.5 notes say nothing of this issue nor anything similar.
Comment #28
dave reid@pthurmond This was committed before the 7.x-1.0 release was even made, so it should be fixed. If you are encountering a bug, please file a new issue instead of commenting on an issue that has been marked as closed for three years.
Comment #29
erwangel commentedI'm sorry to reopen this but although it resolves the subject's issue about image_field min/max resolution, it doesn't implement these settings for the media/file_field as requested by (#1140434: Size limits and other settings like in FileField https://www.drupal.org/project/media/issues/1140434) which was marked as duplicated. So I changed category issue to "feature request". Could we have min/max resolution and the appropriate file_validate_image_resolution for media files also ? This can be useful in many situations especially when allowing users to upload large files pictures as is the case in nowadays with high resolution cameras (even with phone devices) but we don't need to keep all these huge original files for just a web/screen display. Not very friendly to ask users to resize their images before uploading. Of course image styles allow a resize for each display case but this doesn't avoid storage of the useless original mbytes. So we need to resize these photos in a reasonable resolution for a quality display but not store them in their original size.
Comment #30
joseph.olstaderwangel
I'm pretty sure you can resolve this by one of these contrib modules for cropping/resizing. If you find one that serves your use case please let us know.
see the link https://www.drupal.org/node/1179172