just can't seem to figure this one out. an unlimited imagefield in node works perfectly, set to a different imagecache preset for teaser, that works perfectly too - in fact, the whole thing is working great

...but when there are three images in the field on the node, all three flow through to teaser..

any simple way to control so it's 'first image only'?

Comments

idflorin’s picture

You can try something like <?php print $node->field_article_image[0]['view'] ?> I'm ussing this code but for drupal 5 on Haute Fashion.

zilla’s picture

where would this go? and i'm assuming that i must change that field_article_image to my own field name, right?

what does 'view' point to?

idflorin’s picture

-You need to create a custom node-story.tpl.php.
something like

<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">

<?php if ($picture) print $picture; ?>


	<?php if ($page == 0) { ?><h2 class="title"><a href="<?php print $node_url ?>"><?php print $title ?></a></h2><?php }; ?>
	<?php if ($terms) { ?><div class="taxonomy"><?php print t('in'); print $terms ?></div><?php } ?>
	
<?php if ($teaser) : ?>
	<?php print $node->field_story_image[0]['view'] ?>
<?php endif; ?>

	<div class="content"><div class="story-full"><?php print $content ?></div></div>
	
	<span class="submitted"><?php print $submitted ?></span>
	
	<?php if ($links) { ?><div class="links">&raquo; <?php print $links?></div><?php }; ?>



</div>

-setup field_story_image (in your case your field name).
-view point to whatever you are setting up in display settings -> admin/content/types/story/display

idflorin’s picture

I think that way the preview function don't work properly, so you need to save to see the results.

zilla’s picture

thanks. i'm sort of doing this right now with content template (trying to do it anyways, but it feels like it has conflict with a content type that also uses cck in fieldgroups!!)

freeman-1’s picture

A simple workaround is to use two CCK/Imagefield fields. One ("first photo" or "main photo") is set to just 1 'value'. The other ("more photos") is set to unlimited or some other number in the drop-down that you want to limit to.

Then controlling the appearance in teasers/full views can done simply via the "Display Fields" tab in Admin/Content-Type/. You can hide "more photos" field or even set them to thumbnail displays below a larger "main photo".

zilla’s picture

@freeman -that's exactly what i'm doing for one of my content types - and use that same principle to move 'main image' above the story, and 'rest of pics' below...but for a few other content types,i thought that i'd avoid asking users to deal with two image fields...

portait’s picture

I am trying the same with the blog content type using content template and I am able actually getting the desired image result but the content teaser just dissapears.

I am using drupal 6. Any help?

<div class="field field-type-image field-field-blog-image-multiple">
  <h3 class="field-label">Multiple Images</h3>
  <div class="field-items">
    <?php foreach ((array)$node->field_blog_image_multiple as $item) { ?>
      <div class="field-item"><?php print $item[0]['view'] ?></div>
    <?php } ?>
  </div>
</div>
sun’s picture

Status: Active » Closed (duplicate)