Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created May 25, 2012 13:03
Show Gist options
  • Save bangpound/2788011 to your computer and use it in GitHub Desktop.
Save bangpound/2788011 to your computer and use it in GitHub Desktop.
name = File entity hacks
description = Temporary hacks to File entity module.
core = 7.x
php = 5.2.4
<?php
function file_entity_hacks_menu_alter(&$items) {
// Override file upload form page callback to inject new allowed file extensions.
if (module_exists('file_entity')) {
$items['file/add']['page arguments'] = array('file_entity_hacks_file_entity_add_upload');
$items['file/add']['file'] = 'file_entity_hacks.pages.inc';
$items['file/add']['file path'] = drupal_get_path('module', 'file_entity_hacks');
if (module_exists('plupload') && module_exists('multiform')) {
$items['file/add']['page arguments'] = array('file_entity_hacks_file_entity_add_upload_multiple');
}
}
}
<?php
/**
* Upload file form with new file extensions.
*/
function file_entity_hacks_file_entity_add_upload($form, &$form_state, $params = array()) {
module_load_include('inc', 'file_entity', 'file_entity.pages');
$params['file_extensions'] = variable_get('media__file_extensions', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
$form = file_entity_add_upload($form, $form_state, $params);
$form['#submit'] = array('file_entity_add_upload_submit');
return $form;
}
/**
* Mulstiple upload file form with new file extensions.
*/
function file_entity_hacks_file_entity_add_upload_multiple($form, &$form_state, $params = array()) {
module_load_include('inc', 'file_entity', 'file_entity.pages');
$params['file_extensions'] = variable_get('media__file_extensions', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
$form = file_entity_add_upload_multiple($form, $form_state, $params);
$form['#submit'] = array('file_entity_add_upload_multiple_submit');
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment