Skip to content
Bryan Hazelbaker edited this page Jun 13, 2013 · 22 revisions
  • hook_convertfile_info()
  • hook_convertfile_pre_convert()
  • hook_convertfile_post_convert()

hook_convertfile_info()

Declare a new provider and conversion formats. Provider and associated formats will be available as options when configuring file field instances, on the inline conversion form, and on the admin convert tab. Unless a callback is specified, new rules must be created to perform the actual conversion.

Example implementation uses a callback for documentation only. The actual imagemagick hook_convertfile_info() makes use of rules and therefore does not specify a callback function.

Example implementation:

/**
 * Implements hook_convertfile_info().
 *
 * Register our provider and formats with convertfile module.
 *
 * @see convertfile_collect_info()
 */
function cf_imagemagick_convertfile_info() {
  return array(
    // Preface array structure with module machine name.
    'cf_imagemagick' => array(
      // Human friendly name of provider.
      'name' => 'ImageMagick',
      // Extensions that this provider will convert to.
      'types' => array(
        'png' => '.png (image/png)',
        'jpg' => '.jpg (image/jpeg)',
      ),
      // Provider specific options callback (optional).
      'options' => 'cf_imagemagick_options',
      // Provider specific options submission formatter callback (optional).
      'exposed_options' => 'cf_imagemagick_options_exposed',
      // Friendly link for help with this provider (optional).
      'help' => array(
        'url' => 'https://github.com/delphian/drupal-convert-file/wiki/ImageMagick',
      ),
    ),
  );
}

hook_convertfile_pre_convert()

@param stdObject $file @param array $instance @return void

Perform operations on the file before it is converted. As $file is an object it will retain any changes made to it.

hook_convertfile_post_convert()

@param stdObject $file @param array $instance @return void

Perform operations on the file after it is converted. As $file is an object it will retain any changes made to it.

Clone this wiki locally