If someone wants to add advanced file upload validators depending on the context, eg $node instance, has to use hook_field_widget_form_alter and add #upload_validators..but #media element does not respect that because it has its own #media_options that passes to its media browser plugins.
But even instead of passing validators to #upload_validators and pass it in #media_options[global]
file_entity_add_upload() still hardcodes its validators, even something can be in $options array..

well i am gonna attach a patch with the simplest solution i found so far

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ParisLiakos’s picture

Title: Pass upload validators set in hook_field_widget_form_alter() » Allow additional file upload validators in file_entity_get_upload_validators()
Status: Active » Needs review
FileSize
547 bytes
ParisLiakos’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

semei’s picture

Status: Closed (fixed) » Needs work

I still encounter a problem with file_entity_edit_validate() and I suppose that the report belongs here. When I upload a video to my media library using Media: Vimeo (i.e. when I add an external video file from the web) then after the file is added to my library I get the following error message:

Notice: Undefined index: #upload_validators in file_entity_edit_validate() (line 699 of [...]\sites\all\modules\file_entity\file_entity.pages.inc).

  • ParisLiakos committed 63af8b0 on 8.x-2.x
    Issue #1883864 by rootatwc: Allow additional file upload validators in...