Hi everyone !
I am looking for a way to use different Image Cache persets for each of my galleries. (e.g. thre are several sources of pictures and they need to be displayed with different watermarks.
Is there a way to do this with Node Gallery ?

Thank You in advance!
Krish

Comments

scroogie’s picture

Category: feature » support

Node Gallery uses just CCK for the images, so this would be a feature of CCK, not a feature of Node Gallery. You will have to create seperate content types for each of those, and set the image formatter on the "Display Fields" page of CCK.

Otherwise you can work around this by defining your own content type template and adding some custom code that determines which display formatter to use by some own logic.

krishinsh’s picture

Thank You for ideas scroogie. I was also thinking about the content type template possibility but wanted to find out if there is a more decent way to do this.
Will try to implement that.

Any other ideas/examples welcome!

scroogie’s picture

As I said, if you have 3 different watermarks you could have3 different Gallery relationships with 3 different content types for images that use different imagecache presets.

Another possibility would be to program a custom imagecache formatter like Node Gallery does, that calls the correct imagecache preset or image manipulations directly (like imageapi_image_overlay() for watermarks). It's not difficult.

I could probably think of even more approaches, but I'm not sure that would really help you at this point. Perhaps I can give you a better suggestion if you tell me more about what you want to achieve.

Does *every* gallery have a different watermark or is it like categories? Do you want the watermark to be static or is it chosen when creating the gallery (if so, by the editor himself or by some parameter like the date)?

krishinsh’s picture

Thank You for Your replay, scroogie.
I will try to describe the situation that I have.
The site that I am building is publishing photos in galleries. Each gallery consists of 10-100 pictures.
Most of the galleries are owned by the site and has to be overlaid with watermark1 that is static and does not change.
Some of the galleries come from other sources and not owned by the site thus they do not need the overlay.
This means that there could be 2 categories of galleries- one with overlay and other without. In future it is possible that we will need another category with watermark2 thus it would be good to be able to add it when it is necessary.
It would be perfect if user could select the category (e.g. site photos, exteranal photos) when creating the gallery.
Images are uploaded with help of Image FUpload module that is very nice when You have 100 pictures.
Galleries and pictures are displayed using views (e.g. recent galleries, top3 most commented pictures, most viewed etc.). Watermark is necessary only on the full page view where the full picture is displayed.
Currently it is displayed with imagecache perset node-gallery-display.

Thank You again for your help!

scroogie’s picture

Okay, an easy hack would be the following:

- Add a field to your Gallery content type that determines the copyright (or any other condition that influences the watermark). This can e.g. be a textfield, option field, taxonomy field, or whatever suits you best.

- Set the field not to be displayed, on the "Display Fields" tab of CCK.

- create a new imagecache preset that does the resizing and watermark, and name it 'copyright-watermark'

- Override the template of the image field by copying the file content-field.tpl.php from the CCK theme folder to the folder of your active theme . Rename the file to "content-field-field_node_gallery_image.tpl.php".

- in the file you will find a line that says
print $item['view']
replace that with something like this:

 $gallery = node_load($node->gid);
 if ($gallery->{$otherField}[0]['value'] == 'someValue') {
    print theme('imagecache', 'copyright-watermark', $item['filepath']);
 } else {
   print $item['view'];
 }

The if ($gallery->{$otherField}[0]['value'] == 'someValue') is where you determine which imagecache preset to use depending on the other field you added to the content type, where $otherField is the machine readable name of the field.

If you don't want to load the gallery node on every page hit, you could use the node_gallery_taxonomy module and realise the same thing with taxonomies: http://drupal.org/project/node_gallery_taxonomy
This would only change the condition in the template.

You can easily do the same in a custom formatter, a node template, a custom field, a computed field, etc. pp.

justintime’s picture

Just a note that the version on this ticket is NG2, and Node Gallery Taxonomy is for NG3 only.

scroogie’s picture

Wow, and I'm talking about NG3 all the time, so be careful if your using NG2 krishinsh. I can't you help you then, though, I fear, as I joined the development of NG for 3.x.

krishinsh’s picture

Everything worked as You described. I checked and realized that I have version 6.x-3.x-dev installed.
Should I update the version for this issue ?
Cheers,
Krisjanis

dddave’s picture

Version: 6.x-2.0-beta2 » 6.x-3.x-dev
Status: Active » Fixed

;)

So this issue is fixed for you? If not, set back to active.

krishinsh’s picture

Yes. Fixed!
Great Thanks for help!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.