2

I've been searching a lot for this, but no luck. I've created a custom file field along with an instance for my custom content type in the .install file.

I've set up everything except that I want that by default this instance of the file file that I created to upload to the 'private' directory and if it's not defined, to define it with this module.

  $file_download_link_instance = array(
  'field_name' => 'file_download_link',
  'required' => true,
  'entity_type' => 'node',
  'bundle' => $machine_name,
  'label' => t('Files to upload'),
  'settings' => array(
    'file_extensions' => 'txt doc docx pdf ods odt xls xls png jpg jpeg',
    'description_field' => TRUE,
    ),
  'description' => t('Please upload here the files.'),
  'display' => array(
    'default' => array(
      'type' => 'hidden',
      ),
    'teaser' => array(
      'type' => 'hidden',
      ),
  ),
  'locked' => TRUE,
);

I believe that I have to edit the 'settings' array, but I don't know the syntax. Thanks!

  • 1
    I wonder if you might benefit from looking at the examples project? Have a browse of the file example module. – siliconmeadow Nov 10 '13 at 10:33
  • Thanks for the tip, but I couldn't find any relevant information any of the submodules of the examples project. – Canutza Nov 11 '13 at 21:11
0

You just wanted to add attribute file_directory inside the settings array

  'settings' => array(
    'file_directory' => 'myModule/images',
    ),

Here is other attributes that might be added:

  'settings' => array(
    'file_extensions' => 'png jpg jpeg',
    'file_directory' => '',
    'max_filesize' => '20 MB',
    'alt_field' => 1,
    'title_field' => 1,
    'max_resolution' => '300x200',
    'min_resolution' => '200x125',
    'default_image' => 0,
  ),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.