I'm using images to flag nodes on my site, using the code here: http://drupal.org/node/305061

But I'd like to use a different image, a non-obtrusive smaller one, for my teaser. Can't get it to work, however.

I've tried several variations of this code in my template.php:

if ($vars['teaser']) { $image_file = small image } else { $image_file = big image }

Tried the $page var as well, but (of course) not working either.

Does anybody know how to check $teaser in template.php?

Comments

Cheek’s picture

I thought of this simple half working patch yesterday. I put this in my teaser:

$string = flag_create_link('flagname', $node->nid); $string = str_replace("image.png", "image_small.png", $string); echo $string;

This works, but only if the button is not clicked. The AJAX script responsible for replacing the image (naturally) replaces it with the big image.

Any ideas are welcome..

quicksketch’s picture

Category: feature » support

I would suggest not using any image in your HTML at all, but instead add a background-image to your links just through CSS. You can target the "full" and "teaser" versions of the link just by using different CSS selectors.

Cheek’s picture

Status: Active » Closed (fixed)

I guess I could do that as well. Didn't think of targeting the parent div id's in CSS, thanks!

I'd be nice to have the option to do it properly though..

Here's the CSS code for anyone interested:

#PARENTNAME .flag-FLAGNAME a.flag-action {
  background: url(IMGNAME.png) no-repeat 0 0;
  text-indent: -2000px;
  display: block;
  width: 100px;
  height: 100px;
  overflow: hidden;
}

#PARENTNAME .flag-FLAGNAME a.unflag-action {
  background: url(IMGNAME2.png) no-repeat 0 0;
  text-indent: -2000px;
  display: block;
  width: 100px;
  height: 100px;
  overflow: hidden;
}
Anonymous’s picture

Is there any way to make different images display if you are on a specific URL?

pseudo example:
if ($url = "mysite.com/blog/" . $node->nid) {$image_file = big image; } else {$image_file = small image;}