nid); $directory = variable_get('jcarousel_block_directoryimage_directory', '/pictures/$nid'); $thumb_prefix = variable_get('jcarousel_block_directoryimage_prefix', 'thumb_'); $directory = str_replace('$nid', $node->nid, $directory); $root = file_directory_path(); $path = base_path() . $root . $directory; foreach ($files as $file) { $thumb_filepath = $path .'/'. $thumb_prefix . $file; $image_filepath = $path .'/'. $file; if (is_file($thumb_filepath)) { // has thumbnail list($width, $height, $type, $image_attributes) = @getimagesize($thumb_filepath); } else{ // no thumbnail, use original list($width, $height, $type, $image_attributes) = @getimagesize($image_filepath); } $formatted_image = array(); $formatted_image['path'] = $image_filepath; $formatted_image['thumb_path'] = $thumb_filepath; $formatted_image['rel'] = $variables['image_rel']; $formatted_image['width'] = $width; $formatted_image['height'] = $height; $formatted_image['alt'] = ''; $variables['images'][] = $formatted_image; } } function _jcarousel_block_directoryimage_load($nid, $show_error = false) { $files = array(); $directory = variable_get('jcarousel_block_directoryimage_directory', '/pictures/$nid'); $thumb_prefix = variable_get('jcarousel_block_directoryimage_prefix', 'thumb_'); $directory = str_replace('$nid', $nid, $directory); $root = file_directory_path(); $path = $root . $directory; if(!is_dir($path)) { if ($show_error) { drupal_set_message(t('Error in opening directory: %path', array('%path' => $path)), 'error'); } return $files; } $handle = opendir($path); if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { // need ignore more files here. TODO if ($file != "." && $file != ".." && $file != "Thumbs.db" && substr($file, 0, strlen($thumb_prefix)) != $thumb_prefix) { $files[] = $file; } } closedir($handle); } return $files; }