hey,
I'm building a module that makes a custom content type - an audio upload to be precise. I have it already so that it adds the content type with a file upload box, but i cannot find how to change the allowed file extensions value.
I've read through every doc page on hook_field_info and field_create_field twice - as well as all the field_create_instance stuff but none of the methods suggested there seem to work. Below is my code:
<?php //Add Fields
//MP3 Field
$field = array(
'field_name' => 'field_sermon_audio', //Machine Name
'type' => 'file', //type, e.g. file, taxonomy_term_reference, text...
'cardinality'=> 1, //how many of these can there be in one field.
'settings' => array(
'instance_settings' => array(
'file_extensions' => 'mp3', //file extensions (seperated by a comma?)
'file_directory' => 'sermons/audio'), //directory (withing files/ ?)
'label' => t('Audio'), //Label
'description' => t('Store the Audio File'),
'file_extensions' => 'mp3'
),
);
field_create_field($field); //create field
$instance = array(
'field_name' => 'field_sermon_audio',
'entity_type' => 'node',
'label' => 'Audio',
'bundle' => 'sermon', //bundle is a posh name for the content type.
'description' => 'The audio recording of the sermon.',