Theming imagecache content

The more you get into drupal the more you find that it isnt as module as you would hope. I just spent the afternoon trying to find a solution to all my image uploads appearing at the bottom of my posts (Im using image cache with CCK imagefield). For templating this isnt where I would like my images to appear. The main issue is that the relevant string is enbriled in the $content variable.

The solution to get around the problem initially I thought it was the $vars['field_imagename_rendered'] = ''; the %vars vairable coming from the $node.

Since this variable is defined only as a string I just set the value to a blank string. No luck there the content within the node was still getting display. Then I tried to display the image placement in the content by setting the files display to hidden.

'.../admin/content/node-type/article/display'

No luck either as the image is removed and the isn’t a handle for the imagecache.

The work around I went with in the end is that the CCK image field is still passed to the node accessing it can accomplished using

1
$vars['nodeid'] = $node->field_imagename[0]['fid'];

Where the ['0'] signifies the array index if there are more that one image to contend with, you will need to incorporate a conditional to automatically extract the image that you require.

To extract the filename and filepath :

1
2
$vars['imfilename'] = $node->field_imagename[0]['filename'];
$vars['imfilepath'] = $node->field_imagename[0]['filepath'];

I now need to build the filename for the preprocess And its only need on taxonomy pages or pages that aren’t directly nodes

// this will only occur on a node page in other words a page for a full node will not appear on the front page

1
2
3
4
5
6
if (arg(0)=="node")
        {
        }
        else{
                $vars['content'] = '<img src="'.$impath. '" class="floatLeft" />'.$vars['content']
                }

That should do hope some finds some value in the post.