IMG_ASSIST: Teaser Thumbnail image --> Story Page Preview Size Image?
gsh2000 - January 8, 2007 - 21:39
IMG_ASSIST: Teaser Thumbnail image --> Story Page Preview Size Image ?
Hello Drupal’ists….
Anyone know how to have a Story Teaser display the Thumbnail image, and then the Story Page for this Teaser, automatically display the larger Preview Size for this Image?
4.7.3, Using IMAGE module + IMG_ASSIST, Garland Theme
Thanks
Garry, Los Angeles, USA
garry@trantech.com

Maybe Someday
Currently that's not possible, because img_assist works with the Drupal filter system and the output is cached. I've been thinking about changing img_assist (in a future version) to work with the nodeapi hook instead so that it could potentially do something like this (at the expensive of load time -- since output wouldn't normally be cached).
changing img_assist
thanks for the rapid reply... would be great to see this on a future IMG_ASST release...
This image behavior is effectively implemented currently in the IMAGE module, in the Image Gallery … performance overhead a small price to pay…
thanks, GARRY
www.joo2joo.org
imagecache
If you're not afraid of a little php, I'd recommend imagecache (http://drupal.org/project/imagecache) and a custom template for the story node type.
Ronan
------------------------------------
Gorton Studios - Websites that Work. http://www.gortonstudios.com/
http://www.gortonstudios.com/portfolio/technologies/drupal
hook_nodeapi solution
I had the same problem and addressed it with hook_nodeapi, like so...
<?php
function custom_nodeapi(&$node, $op, $a3, $a4) {
if ($op == 'view') {
// For teasers, show thumbnails, not full images
if ($a3) {
//drupal_set_message("custom_nodeapi($op)" . dpr($node->teaser, 1));
// modify the img tags inserted by img_assist
$teaser = preg_replace('/<img src="([^"]*)\.([^\."]*)\.([^\."]*)" ([^>]*) class="image ([^"]*)"([^>]*)>/',
'<img src="$1.thumbnail.$3" $4 class="image thumbnail" />',
$node->teaser);
//drupal_set_message("new teaser: " . dpr($teaser, 1));
$node->teaser = $teaser;
}
}
}
?>
Please elaborate
yogadex,
Can you elaborate briefly where you put that code and which variables are passed on to the function?
Thanks, riemann
Found the solution myself
There's a good description on how to use custom_nodeapi() on http://www.angrydonuts.com/the_nuisance_of_the_read_more_fl
Additionally, I slightly changed the code given above in order to make it work with my installation and I also got rid of the caption:
<?php
function custom_nodeapi(&$node, $op, $a3, $a4) {
if ($op == 'view') {
// For teasers, show thumbnails, not full images
if ($a3) {
// drupal_set_message("custom_nodeapi($op)" . dpr($node->teaser, 1));
// modify the img tags inserted by img_assist
$teaser = preg_replace('/<img class="image ([^"]*)" src="([^"]*)\.([^\."]*)\.([^\."]*)" ([^>]*) width="([^"]*)" height="([^"]*)" ([^>]*)>/',
'<img class="image thumbnail" src="$2.thumbnail.$4" $5 $8>',
$node->teaser);
// get rid of caption layer inserted by img_assist
$teaser = preg_replace('/<span style="([^"]*)" class="caption">(.*?)<\/span>/',
'',
$teaser);
// drupal_set_message("new teaser: " . dpr($teaser, 1));
$node->teaser = $teaser;
}
}
}
?>
Excerpt + Image assist
I just use the excerpt module with the image assist module. In the "teaser" area produced by the excerpt module I put a thumbnail image selected from image assist, and in the main body I make a separate selection and put a preview size image. Works great. No hassle.
Anyone know if this works
Anyone know if this works in 5.7? I can't get it to work, any ideas?
Drupal 5.7
By replacing $node->teaser" with "$node->content[body]['#value']" the above snippet worked for me in Drupal 5.7