Index: xspf_playlist_thumb/xspf_playlist_thumb.module =================================================================== --- xspf_playlist_thumb/xspf_playlist_thumb.module (revision 902) +++ xspf_playlist_thumb/xspf_playlist_thumb.module (working copy) @@ -50,7 +50,6 @@ } } - /* ******************************************************* */ /* XSPF PLAYLIST HOOKS */ /* ******************************************************* */ @@ -68,20 +67,24 @@ */ function xspf_playlist_thumb_xspf_playlist_item_alter(&$item, $node, $url) { // Look for modules that return potential thumbs. + // take module weights into consideration. $modules = variable_get('xspf_'. $node->type .'_thumb', false); if ($modules) { foreach ($modules as $module) { - // split the name into parts list($module_name, $separator, $config) = split('[--]', $module); + $possible_modules[$module_name] = $config; + } + $all_modules = module_list(); + $modules = array_intersect_key($all_modules, $possible_modules); + + foreach ($modules as $module) { // invoke the thumbnail hook - if (module_exists($module_name)) { - if ($thumb = module_invoke($module_name, 'xspf_playlist_thumbnail', 'return', $node, $config)) { - // Some modules may pass back an array. Only take the first item - if (is_array($thumb)) {$thumb = $thumb[0]; } - // We're only returning the specified thumb. - xspf_playlist_item_set_value($item, array('key' => 'image', 'value' => $thumb), false, false); - return; - } + if ($thumb = module_invoke($module, 'xspf_playlist_thumbnail', 'return', $node, $possible_modules[$module])) { + // Some modules may pass back an array. Only take the first item + if (is_array($thumb)) {$thumb = $thumb[0]; } + // We're only returning the specified thumb. + xspf_playlist_item_set_value($item, array('key' => 'image', 'value' => $thumb), false, false); + return; } } } @@ -191,10 +194,12 @@ function xspf_playlist_thumb_get_cck_imagefield_files($node,$field_name) { if (isset($node->{$field_name})) { $thumbs = array(); - foreach($node->{$field_name} as $field) { - $thumbs[] = $GLOBALS['base_path'] . $field['filepath']; + foreach ($node->{$field_name} as $field) { + if ($field['filepath']) { + $thumbs[] = $GLOBALS['base_path'] . $field['filepath']; + } } - return $thumbs?$thumbs:''; + return $thumbs? $thumbs: ''; } }