Hi there, I am trying to build a node type which contains:
- a preview imagefield (field_image_thumb) with imagecache preset (desaturate_-_resize_182px-110px)
and:
- a fullsize imagefield (field_image_full) with imagecache preset (scale_500px_max)
(... using 2 different fields because the preview is supposed to be a manually generated detail view.)
now i am working on a node-type.tpl.php which is supposed to call for field_image_thumb (imagecached version) and link it to (imagecached version of) field_image_full ... in lightbox2 mode.
--
I realized everything besides the fact that i can just link onto a lightbox'ed ORIGINAL version of field_image_full. I cant get the .tpl.php to make it use the imagecached fullsized picture.
her is the code i used so far:
<?php
// Format the teaser image
if ($field_image_standard_thumb) {
$image_standard_thumb = theme('imagecache', 'desaturate_-_resize_182px-110px', $field_image_standard_thumb[0]['filepath'], $node->title, $node->title);
}
?>
<div class="node">
<?php // Teaser view
if ($teaser): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<div class="meta">
<?php if ($submitted): ?>
<span class="submitted"><?php print $submitted ?></span>
<?php endif; ?>
<?php if ($submitted): ?>
<span class="terms"> in <?php print $terms ?></span>
<?php endif; ?>
</div>
<div class="content">
<div class="field field-type-image field-field-image-standard-thumb imagefield-nodelink">
<div class="field-items">
<div class="field-item odd">
<?php // Print the teaser image as a link to the full node.
print l($image_standard_thumb, 'node/'. $nid, array('html' => 'TRUE')) ?>
</div>
</div>
</div>
<?php print $node->content['field_text_main']['#children'] ?>
<!-- Other content here -->
</div>
<?php // Full view
else: ?>
<div class="meta">
<span class="submitted"><?php print $submitted ?></span><span class="terms"> in <?php print $terms ?></span>
</div>
<div class="content">
<div class="field field-type-image field-field-image-standard-thumb imagefield-gallerylink">
<div class="field-items">
<div class="field-item odd">
<?php // Print the teaser image again, but this time link it to the full image using Lightbox2.
print l($image_standard_thumb, $field_image_standard_full[0]['filepath'], array('html' => 'TRUE', 'attributes' => array('class' => 'imagefield-field-image-standard-thumb', 'rel' => 'lightbox'))) ?>
</div>
</div>
</div>
<?php print $node->content['field_text_main']['#children'] ?>
<!-- Other content here -->
</div>
<?php endif ?>
</div>
I am pretty stuck now because my php aint the best - so - any help ist greatly appreciated!
Comments
Comment #1
stella commentedHi,
Perhaps try something like this:
Cheers,
Stella
Comment #2
mimhakkuh commentedThanks a LOT! Stella - your snippet of code did it! :)
... except for one unneccessary closing bracket ... i used this:
Comment #3
stella commentedCool, glad it's working.
Cheers,
Stella
Comment #4
mimhakkuh commentedSorry to bother again - I have just found something not working properly with this variation of the code:
... I wrote:
... to import the Image's Alt and Title Information - the title information should be output within the Lightbox caption. However, since I use this line, the node's title is beeing put into my image title & caption.
I ve read the whole documentation and looked in the forum but didn't find a hint on how to custom-integrate Image: Title- and Alt-Text.
Any hints are very welcome!
Comment #5
stella commentedIf no caption is provided in the rel attribute, then lightbox defaults to using the image title / alt text. This is expected and desired behaviour.
Cheers,
Stella
Comment #6
mimhakkuh commentedI was wondering how to use the variable for the title in this context. It worked this way:
Comment #7
stella commentedI'm not sure I follow your question... would you mind elaborating?
Comment #8
mimhakkuh commentedOkay, I will try:
First, I used this line in my node-type.tpl.php:
This made my node show a imagefield_standard_thumb which was linked to "imagefield_standard_full" via the lightbox. Though, no caption at all was shown in Lightbox (no node's title either). And I wanted to make Use of an imagecache preset for the fullsize image.
Next step was this variation - to include the imagecache preset for imagefield_standard_full (comment #1-2):
Now, my lightbox presentations made use of the desired imagecache preset - but still - I did not get any caption ... due to this problem, I was asking for the proper way to print an image's title text so lightbox could use this (comment #4).
I tried following code to get the caption put out correct from the image title text, but this did not work correctly - though, I was now having the node's title printed as a caption (comment #4):
Finally, the caption is put out correctly by using this code (comment #6):
Thx to Stella for the help!