Index: slideshowbox.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/slideshowbox/slideshowbox.module,v retrieving revision 1.1 diff -u -p -r1.1 slideshowbox.module --- slideshowbox.module 5 Dec 2006 10:58:52 -0000 1.1 +++ slideshowbox.module 3 Oct 2007 13:43:20 -0000 @@ -120,6 +120,18 @@ function slideshowbox_admin_settings() { '#default_value' => variable_get('slideshowbox_term', ''), ); + $options_size = array('_original' => '_original'); + foreach (_image_get_sizes() as $preset) { + $options_size[$preset['label']] = $preset['label'] .' ('. $preset['width'] .'x'. $preset['height'] .')'; + } + $form['slideshowbox_image_size'] = array( + '#type' => 'select', + '#title' => t('Image size'), + '#description' => t('Select an image size to display images in.'), + '#options' => $options_size, + '#default_value' => variable_get('slideshowbox_image_size', '_original'), + ); + $form['slideshowbox_type'] = array( '#type' => 'select', '#title' => t('Slideshow type'), @@ -341,37 +353,36 @@ function slideshowbox_getAllTerms(){ * Get all images to a given Term */ function slideshowbox_getTermImages(){ - $path = 'http://'.$_SERVER['HTTP_HOST'].base_path(); $termId = variable_get('slideshowbox_term', 0); - $limit = 'LIMIT 0, '.variable_get('slideshowbox_max_images', 10); + $limit = variable_get('slideshowbox_max_images', 10); // return if no Term was selected if (!$termId) - return; + return ''; $sort = variable_get('slideshowbox_sort', ''); - $sort = $sort ? 'n.'.$sort.' '.variable_get('slideshowbox_sort_order', 'DESC') : ''; + $sort = $sort ? 'n.' . $sort .' '. variable_get('slideshowbox_sort_order', 'DESC') : ''; $rand = variable_get('slideshowbox_random', 1) ? 'RAND()' : ''; if($sort OR $rand) - $order = "ORDER BY $rand $sort "; + $order = "ORDER BY $rand $sort"; // load all nodes they fit to the given term-Id - $results = db_query("SELECT n.nid - FROM {node} n INNER JOIN term_node ON n.nid = term_node.nid - WHERE n.type = 'image' AND term_node.tid = $termId AND n.status = 1 $order $limit"); + $results = db_query_range("SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE n.type = 'image' AND tn.tid = %d AND n.status = 1 $order", $termId, 0, $limit); // load nodes from the result + $output = ''; + $size = variable_get('slideshowbox_image_size', '_original'); while ($node = db_fetch_object($results)){ - $node = node_load($node->nid, NULL, TRUE); - $image = (object)$node->images; - $file = $path.'files/'.($image->slideshow ? $image->slideshow : $image->_original); - $link = $path.'node/'.$node->nid; - $title = $node->title; - $desc = trim(strip_tags($node->body)); - $images .= "mySlideData[countArticle++] = new Array('$file', '$link', '$title', '$desc');"; + $node = node_load($node->nid); + $images = (object)$node->images; + $file = base_path() . file_directory_path() .'/'. (isset($images->$size) ? $images->$size : $images->_original); + $link = url('node/'. $node->nid); + $title = check_plain($node->title); + $desc = check_plain(trim($node->body)); + $output .= "mySlideData[countArticle++] = new Array('$file', '$link', '$title', '$desc');"; } - return $images; + return $output; }