By primz on
Hi there,
I have a story category that will always contain an image in exactly the same place for every post. Is there a way to attach an image to the story when posted, that I can extract out in the template code? Ie. so I'm not importing an image into actual post input? Thanks, p.
Comments
you could use cck module
you could use cck module with image field. Else you could use image module and create yourself a new module (content type) with the extra image field. More on the cck vs own modules
Luck
thanks
thanks folkbert, that worked a treat -
for anyone doing this in the future, i installed the CCK + CCK imagefield modules, as well as the Contemplate module, and then used:
print $node->field_story_thumb[0]['view'];to display my thumbnail in the node.tpl.php file.
note: the field_story_thumb object name is because i named my field 'Story Thumb' - it will be different on what you name yours. hope that helps someone in future. best, p.
Why not image_attach?
Is there a reason the image_attach.module doesn't do this anymore?
Using this module in drupal 4.7 I got an image exactly where I wanted it, at the top right of each node display.
With the same theme and the same CSS in drupal 5.1, it drops to the bottom right and stays there no matter what I do.
Still stuck here.
I'm still having this problem. In fact, I almost replied "same here" before realizing this is my own post from several months ago.
The problem seems to stem from what happens when the theme template calls $content for outputting a node body or teaser. Eventually, the function theme_image_attach_teaser gets called; that takes the $node object, finds an attached image, and then outputs ONLY the image itself. That's how it does in 5.1, anyway.
Later on, somewhere else-- either in the core or in the template engine, the choice is made that the node body or teaser gets output first, and the attached image gets output after.
Once things are done in that order, I'm pretty much stuck. There's no CSS trick I know of that would consistently reposition that image, output after the node body, back up to the top.
Under 4.7, the theme_image_attach_teaser function took the teaser, added the image display, and returned the combined object as $node->body. It was easy, in this case, just to use the template.php file in your own template to override the order in which it combined the two objects to suit your taste.
Now, I can't even find where this process is done. I can override the teaser function in the theme to pull out the attached image, and then the body, but in that case, just about everything else goes missing-- books don't work, attached files don't work-- anything that is not explicitly a part of $node->body just goes away.
In the theme I'm using, the default is just to echo $content, the entire object (array?). I suppose what is necessary to do is pull apart that array, spit out the attached image first, and then everything else. I'm not sure I even know how to go about finding out what's included in "everything else", though.