It happens quite regularly that pictures are different according to the 'situation' of a page. For instance, on my site, pictures in full node view are bigger than when the teaser of that node is shown on the frontpage. In full node, there is a caption, on the frontpage, there is no caption. There may be other situations imaginable in which the same picture is shown differently according to circumstances.

I was wondering if this can be accomplished with Imagepicker.

That would boil down to some sort of conditional css class, I would assume, a class which can be different according to the situation. Something like "if $teaser, then style="img_teaser_true", else style = "img_teaser_false".

The inserted style is "hard coded", i.e. it is part of what is written to the database. That's where I run into a wall.

Does this sound like rubbish, or can it be done?

Comments

hutch’s picture

This is a theming issue, not an Imagepicker issue, but I'll answer it anyway.

I notice that teasers are wrapped in a div with a css class 'node-teaser' but the full node is not. I haven't tried it but you might be able to do something like

. node-teaser .imgp_title {
display: none;
}

in your theme stylesheet.

By the way, the most recent version of dev allows you to manipulate the HTML that is inserted. Just copy imagepicker_insert_template.txt.example to imagepicker_insert_template.txt and edit it.

modul’s picture

Thanks for your reply, Hutch. I don't think "node-teaser" is available in all themes, though. It should be.

I “solved” my problem in the meantime, by doing a str_replace of the class name in $content in node.tpl.php, when $teaser is true. That doesn’t feel very ‘clean’, though. But it works.

As you say, it’s a theming problem, but it’s partly related to Imagepicker too. The class names from the example.txt template are “hard-coded” in the database, which means that they are supposed to be applicable in all situations (full view, teaser view, Panel constructions, Views results etc.). That may be the case, or it may not. It would be nice if this class name were a variable: “When in Teaser, then use class X, but when you’re in Full View, then use class Y, and when you’re in Panels, use class Z”, something like that. I have not seen anything like this, though.

Come to think of it: it would be sooooo nice if variables were allowed in a css stylesheet…:
if ($teaser): h2 {color: green;} else: {color: blue} endif
Something like that.

Of course, this is trivial in a template file, but this approach boils down to mixing style and content, the separation of which was, when I’m correct, the whole idea of designing CSS in the first place. I like to keep my style business in my css’s.

Anyway, my particular problem is solved, and I’m going to use Imagepicker at full speed now. Thanks for a truly Fine module!

hutch’s picture

Just getting rid of this damn spammers tags

hutch’s picture

Status: Active » Closed (fixed)