Great, clean module!
I propose a cleaner way to do one thing in the vimeo_download_thumbnail($id, $url), starting at line 468 in vimeo.module,v 1.1.2.2 2010/02/20 11:10:32. Basically, get rid of the if statement and replace with the one-liner, file_check_directory($dir, 1);. With $mode set to 1 in the D6 file_check_directory function, it will create the directory and test it for you. No need to check to see if it exists, because if Drupal can't create the directory because of a permissions problem, it will message you.
Down the road, I'd like to see this directory check moved to the admin/set-up arena, instead of each time the module is fired. It causes some issues with other modules, like filefield and the ahah stuff (http server response 0).
<?php
function vimeo_download_thumbnail($id, $url) { // Line 468
//Check if the containing folder exists -- if not, create it.
$dir = file_directory_path() .'/vimeo-originals';
file_check_directory($dir, 1); // <-- R&R'ed line
//Setup local filename
$src = file_create_path() . '/vimeo-originals/' . $id . '.jpg';
$result = drupal_http_request($url);
$code = floor($result->code / 100) * 100;
$types = array('image/jpeg');
if ($result->data && $code != 400 && $code != 500 && in_array($result->Content-Type, $types)) {
$src = file_save_data($result->data, $src, FILE_EXISTS_REPLACE);
return TRUE;
}
}
?>
Reference: http://api.drupal.org/api/function/file_check_directory/6
Comments
Comment #1
jdelaune commentedThanks I'll commit it soon.