147c147
< case 'hide':
---
> case 'hide':
150c150
< case 'above':
---
> case 'above':
158c158,167
< return $node;
---
> break;
>
> case 'alter':
> $node->body = preg_replace("/\[image:(pic|thumb):(-?\d{1,2}):?(\w+)?\]/ie",
> "_node_images_filtered_img ($node->nid, strtolower('$1'), strtolower('$2'), strtolower('$3'))",
> $node->body);
> $node->teaser = preg_replace("/\[image:(pic|thumb):(-?\d{1,2}):?(\w+)?\]/ie",
> "_node_images_filtered_img ($node->nid, strtolower('$1'), strtolower('$2'), strtolower('$3'))",
> $node->teaser);
> break;
508a518,594
> /**
> * Reformat [IMAGE] tags into
tags
> *
> * @param $nid
> * the nodeID of this node (if it has one)
> * @param $style
> * the style of image tag:
> * - 'pic' the picture at the origional size
> * - 'thumb' the thumbnail picture that links to the full size picture
> * @param $weight
> * the weight of the desired picture and the index into the node_images array
> * @param $align
> * the alignment to use for the image
> * @return
> * the filtered image tag string
> */
> function _node_images_filtered_img ($nid, $style='thumb', $weight=0, $align='')
> {
> $default = '[IMAGE:'.$style.':'.$weight;
> if ($align)
> $default .= ':'.$align;
> $default .= ']';
>
> if ($nid == '0')
> return $default;
> $sql = db_query('SELECT * FROM {node_images} WHERE nid=%d AND status=1 ORDER BY weight', $nid);
> $rc = 0;
> while ($r = db_fetch_object($sql)) {
> // Place the images in an array by their weight - note if there are
> // multiple images of the same weight then only the last one will
> // remain in the array.
> $node_images[$r->weight] = $r;
> $rc++;
> }
> if ($rc==0)
> return $default;
>
> if (isset($node_images[(int)$weight]))
> $image = $node_images[(int)$weight];
> else
> return $default;
>
> $output = '';
> $description = check_plain($image->description);
>
> if ($info = getimagesize($image->filepath)) {
> $width = $info[0] + 36;
> $height = $info[1] + 36;
> }
> else {
> $width = 420;
> $height = 315;
> }
>
> if ($style == 'thumb') {
> $imgTag = strtr('
',
> array('%thumbpath'=>file_create_url($image->thumbpath),
> '%description'=>$description,
> '%align'=>$align));
>
> $output .= ''.$imgTag.'';
> }
> else {
> $imgTag = strtr('
',
> array('%filepath'=>file_create_url($image->filepath),
> '%description'=>$description,
> '%align'=>$align,
> '%width'=>$width,
> '%height'=>$height));
> $output .= $imgTag;
> }
>
> return $output;
> }
>
>