Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

avatar_selection_file_download

Definition

avatar_selection_file_download($file)
contributions/avatar_selection/avatar_selection.module, line 1088

Description

Implementation of hook_file_download().

Ensure that user pictures (avatars) are always downloadable.

Parameters

$file The path to the file that will be checked if downloadable.

Return value

An array containing the file mime type and size, generated by the array() function, if everything is fine. NULL, if the file is not downloadable.

Code

<?php
function avatar_selection_file_download($file) {
  if (user_access('access content')) {
    $data = explode('/', $file);
    $icon = array_pop($data);
    $folder = implode('/', $data);
    if ('avatar_selection' == $folder) {
      $info = image_get_info(file_create_path($file));
      return array(
        'Content-type: '. $info['mime_type'],
        'Content-length: '. $info['file_size'],
      );
    }
    else {
      return null;
    }
  }
}
?>