Index: taxonomy_image.admin.inc =================================================================== --- taxonomy_image.admin.inc (revision 26) +++ taxonomy_image.admin.inc (working copy) @@ -58,6 +58,35 @@ '#description' => t('Subdirectory in the directory "%dir" where category pictures will be stored. Lower case is recommended. ', array('%dir' => $files_path)) . $error, ); + if (module_exists('embed_views')) { + $views = array(); + foreach (views_get_all_views() as $view_name => $view) { + // Don't list default views in the selection options + if ($view->type == 'Default') { + continue; + } + foreach ($view->display as $display_name => $display) { + $views[$view_name . '__' . $display_name] = "$view_name $display_name"; + } + } + + $form['general']['taxonomy_image_view'] = array( + '#type' => 'fieldset', + '#title' => t('Taxonomy view settings'), + ); + $form['general']['taxonomy_image_view']['taxonomy_image_use_views'] = array( + '#type' => 'checkbox', + '#title' => t('Use a view to select the term images'), + '#default_value' => variable_get('taxonomy_image_use_views', NULL), + ); + $form['general']['taxonomy_image_view']['taxonomy_image_view'] = array( + '#type' => 'select', + '#title' => 'Select the view', + '#options' => $views, + '#default_value' => variable_get('taxonomy_image_view', NULL), + ); + } + $form['general']['taxonomy_image_disable'] = array( '#type' => 'textarea', '#rows' => 1, Index: taxonomy_image.module =================================================================== --- taxonomy_image.module (revision 26) +++ taxonomy_image.module (working copy) @@ -98,7 +98,10 @@ // Make sure the attributes don't try to override the preset. unset($attributes['width'], $attributes['height']); $mypath = variable_get('taxonomy_image_path', 'category_pictures') .'/'; - $return_url = theme('imagecache', $preset, $mypath . $current->path, $current->name, $current->title, $attributes); + // If 'fullpath' is set then don't use the standard + // category_pictures path + $mypath = $current->fullpath ? $current->path : $mypath . $current->path; + $return_url = theme('imagecache', $preset, $mypath, $current->name, $current->title, $attributes); } } if ($wrapper) { @@ -243,6 +246,22 @@ if ($image[$tid] = db_fetch_object(db_query('SELECT i.path, d.name, d.description FROM {term_image} i INNER JOIN {term_data} d USING(tid) WHERE i.tid=%d', $tid))) { $image[$tid]->url = file_create_url($mypath . $image[$tid]->path); } + elseif (variable_get('taxonomy_image_use_views', FALSE)) { + // Use the specified view to set the taxonomy image + list($view_id, $display_id) = explode('__', variable_get('taxonomy_image_view', '')); + $view = views_get_view($view_id); + $result = $view->preview($display_id, $tid); + $result = strip_tags($result); + // Remove the admin links + $result = preg_replace('/Export|Edit|Clone/', '', $result); + // Remove extra whitespace + $result = trim($result); + if ($result) { + $image[$tid]->path = $result; + $image[$tid]->url = url($image[$tid]->path); + $image[$tid]->fullpath = TRUE; + } + } elseif ($recursive) { // Walk up the taxonomy hierarchy and look for an image. $orig = $tid; @@ -265,8 +284,13 @@ if (!empty($image[$tid]->path)) { $image[$tid]->tid = $tid; $image[$tid]->vid = $term->vid; - $img = getimagesize($fullpath . $image[$tid]->path); + if ($image[$tid]->fullpath) { + $img = getimagesize($image[$tid]->path); + } + else { + $img = getimagesize($fullpath . $image[$tid]->path); // $img = getimagesize($image[$tid]->url); + } // Make sure it worked. if (!$img) { return NULL;