? inline.attachment_4.patch ? inline_doxygen.patch ? inline_make_previews_work.patch ? inline_only_when_filter_is_active.patch Index: inline.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/inline/inline.module,v retrieving revision 1.14 diff -u -F^f -r1.14 inline.module --- inline.module 3 May 2006 23:16:52 -0000 1.14 +++ inline.module 16 Jul 2006 10:16:48 -0000 @@ -110,6 +110,7 @@ function inline_filter_tips($delta, $for function inline_nodeapi(&$node, $op, $arg) { if(is_array($node->files) && $op == 'view') { + //TODO: we should *really* us the filter hooks for this, not? $node->teaser = _inline_substitute_tags($node, 'teaser'); $node->body = _inline_substitute_tags($node, 'body'); @@ -124,24 +125,37 @@ function _inline_fileobj(&$node, $id) { $n=1; foreach ($node->files as $file) { if ($n == $id) { - return $file; + return (object)$file; } ++$n; } return NULL; } - else - { + else { foreach ($node->files as $file) { if ($file->filename == $id) { - //return array($file->filename, $file->filepath); - return $file; + return (object)$file; } } return NULL; } } +/** + * Prepares the file object + */ +function inline_prepare_file_object($file) { + $file = (object)$file; + $tmp = file_directory_temp(); + if (strpos($file->filepath, $tmp) === 0) { + $file->real_path = $file->filepath; + $file->filepath = $file->filename; + $file->preview = TRUE; + } + return $file; +} + + function theme_inline_as_link($file) { return l(($file->description ? $file->description : $file->name), file_create_url($file->filepath), @@ -173,7 +187,6 @@ function theme_inline_add_to_body($node, } function _inline_auto_add($node) { - $inline_file = _inline_fileobj($node, $value); //0 Disabled //1 Only in teaser //2 Only in body @@ -181,6 +194,7 @@ function _inline_auto_add($node) { switch (variable_get('upload_inline_'. $node->type, 0)) { case 1: foreach ($node->files as $fid => $file) { + $file = inline_prepare_file_object($file); if (_inline_decide_img_tag($file)) { $node->files[$fid]->inline = TRUE; $node->teaser = theme('inline_add_to_teaser', $node, $file); @@ -192,6 +206,7 @@ function _inline_auto_add($node) { break; case 2: foreach ($node->files as $fid => $file) { + $file = inline_prepare_file_object($file); if (_inline_decide_img_tag($file)) { $node->files[$fid]->inline = TRUE; $node->body = theme('inline_add_to_body', $node, $file); @@ -203,6 +218,7 @@ function _inline_auto_add($node) { break; case 3: foreach ($node->files as $fid => $file) { + $file = inline_prepare_file_object($file); if (_inline_decide_img_tag($file)) { $node->files[$fid]->inline = TRUE; $node->teaser = theme('inline_add_to_teaser', $node, $file); @@ -223,7 +239,7 @@ function _inline_substitute_tags(&$node, $map[$value] = $key; $titl = $match[3][$key]; $ytype = $match[1][$key]; - $file = _inline_fileobj($node, $value); + $file = inline_prepare_file_object(_inline_fileobj($node, $value)); $replace = ""; if ($file->fid != NULL) { //decide if we should show a link or an img tag @@ -253,10 +269,18 @@ function _inline_substitute_tags(&$node, function _inline_decide_img_tag($file) { $inlined = array('jpg', 'jpeg', 'pjpeg', 'gif', 'png'); $mime = array_pop(explode('/', $file->filemime)); + if (in_array($mime, $inlined)) { // read settings list($maxwidth, $maxheight) = explode(',',variable_get('inline_img_dim', '150,150')); - list($width, $height) = getimagesize($file->filepath); + + if ($file->preview) { + list($width, $height) = getimagesize($file->real_path); + } + else { + list($width, $height) = getimagesize($file->filepath); + } + if (($width && $height) && ($width < $maxwidth && $height < $maxheight)) { return TRUE; }