size limits and other settings like in FileField
file sizes, image sizes, etc
new functionality? merge something?

might be having a brain fart again, but we need this

http://drupal.org/node/1101964#comment-4400734

Comments

Do I understand correctly that curently media field do not have file size limits implemented?

On a site I manage, I cannot choose the max file size for an audio field. File size is arbitrarly set at 32 mb. Any file bigger than that is rejected. At php level (and drupal file field), file size is limited to 300mb.

Should I revert to simple file field to be able to increase this limit, or did I miss something ?

I hope media will one day work as an extension to core file field (and inherit file field features) to avoid code duplication ;-)

I'm assuming LPCA means image dimension settings (or resolution) for the image size (not the File size - as Media does this). In the Image field you can limit the dimensions of an image on upload given as 'Maximum image resolution'. This means you can set a maximum width and height for all your images, thereby making pages load faster, and doing away with original images going off the screen.

So a request for a maximum (and/or minimum) image size resolution (width & height) as is available in the image field of the core ckk.

Perhaps this could be set under the Media Types->Image settings for a global approach or in the Media asset field in the content-type setup.

I also have a need to be able to set limits on the dimensions for images uploaded to Media.

It seems to me like Drupal Gardens does this, but I can't quite figure out how it is working with all the settings I am able to view.

Maybe someone knows how to cobble together a custom module that would resize images to a specified resolution limits for all Media Images. I wouldn't care about a UI for such a temporary workaround.

Here are some initial observations:

  • The standard image field setup the size validation in image_field_widget_form (modules/image/image.field.inc, line 304)
  • The equivalent media function is media_field_widget_form (media/includes/media.fields.inc line 217)
  • There is a little @todo in the media_field_widget_form that make me think there will be some more work needed (to pass field settings to the popup, but not sure about this)
  • Needs to handle 2 different validations. Images uploaded and images selected from the library.

edit: some more:

  • The popup is created in media.browser.inc (media_media_browser_plugin_view line 209). It seems $params doesn't contains the field instance settings like minimum image size.
  • The forms are created in media.pages.inc (media_add_upload line 171 and media_add_upload_multiple line 259(

So, for uploaded files I could imagine something as simple as:

<?php
if ($settings['max_resolution'] || $settings['min_resolution']) {
 
$validators['file_validate_image_resolution'] = array($settings['max_resolution'], $settings['min_resolution']);
}
?>

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?

Status:Active» Closed (duplicate)