--- Image.php.orig 2009-05-06 12:22:34.000000000 +0200 +++ Image.php 2009-05-06 12:22:45.000000000 +0200 @@ -54,8 +54,17 @@ class Text_Wiki_Render_Xhtml_Image exten $src = $options['src']; if (pearwiki_filter_use_image($pearwiki_current_format)) { + $image = false; + // check if image node exists for this name - $image = db_fetch_object(db_query("SELECT n.nid, n.title, f.filename, f.filepath FROM {node} n LEFT JOIN {files} f ON n.nid = f.nid WHERE n.status = 1 AND n.type = 'image' AND LOWER(n.title) = LOWER('%s') LIMIT 1", $src)); + if (module_exists('image')) { + $image = db_fetch_object(db_query("SELECT n.nid, n.title, f.filename, f.filepath FROM {node} n LEFT JOIN {files} f ON n.nid = f.nid WHERE n.status = 1 AND n.type = 'image' AND LOWER(n.title) = LOWER('%s') LIMIT 1", $src)); + } + + // Look for attached images otherwise + if (!$image) { + $image = db_fetch_object(db_query("SELECT filename as title, filepath FROM {files} WHERE LOWER(filename) = LOWER('%s') LIMIT 1", $src)); + } if ($image) { $src = file_create_url($image->filepath); if (!isset($options['attr']['alt'])) { @@ -64,7 +73,7 @@ class Text_Wiki_Render_Xhtml_Image exten if (!isset($options['attr']['title'])) { $options['attr']['title'] = $image->title; } - if (!isset($options['attr']['link'])) { + if (!isset($options['attr']['link']) AND !empty($image->nid)) { $options['attr']['link'] = url("node/$image->nid", null, null, true); } }