user_file_download

Definition

user_file_download($file)
modules/user/user.module, line 433

Description

Implementation of hook_file_download().

Ensure that user pictures (avatars) are always downloadable.

Code

<?php
function user_file_download($file) {
  if (strpos($file, variable_get('user_picture_path', 'pictures') .'/picture-') === 0) {
    $info = image_get_info(file_create_path($file));
    return array('Content-type: '. $info['mime_type']);
  }
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.