Overriding the default IMAGE GALLERY page layouts when using the image.module

Dublin Drupaller - December 15, 2005 - 13:59

Hi Guys,

I was trying to change the default layout of how the image.module displays IMAGE GALLERY pages with Drupal version 4.6.x and was tempted to hack the image.module but decided to setup a template override instead.

The image.module is a superb module and the default layout is fine..I just wanted to put some extra appropriate (and dynamic) content above the thumbnails, but, I knew that once I had hacked the image.module I would be making life much more difficult at a later stage when trying to upgrade or tweak that ammendment even more.

In essence the override gives you control at the $content level which is a step up from just having a node-image.tpl.php file in your theme folder.

I have posted the simple step-by-step approach in the handbook page called EXAMPLE - THEMING THE IMAGE GALLERY PAGES which is simple enough for non-php programmers to follow (carefully).

Instead of cluttering up the handbook page..I thought I would post a forum topic related to the book page so people can paste or post additional snippets/tricks etc. here instead.

I hope that's of use to others..

Dub

bug in the Drupal Site..

Dublin Drupaller - December 15, 2005 - 14:19

There's a bug that won't allow me to post this code in the handbook...here's the default image_gallery.tpl.php file

<?php
 
// We'll add height to keep thumbnails lined up.
 
$size = _image_get_dimensions('thumbnail');
 
$width = $size['width'];
 
$height = $size['height'];

 
$content = '';
  if (
count($galleries)) {
   
$content.= '<ul class="galleries">';
    foreach (
$galleries as $gallery) {
     
$content .= '<li>';
      if (
$gallery->count)
       
$content.= l(image_display($gallery->latest, 'thumbnail'), 'image/tid/'.$gallery->tid, array(), NULL, NULL, FALSE, TRUE);
     
$content.= "<h3>".l($gallery->name, 'image/tid/'.$gallery->tid) . "</h3>\n";
     
$content.= '<div class="description">'. check_output($gallery->description) ."</div>\n";
     
$content.= '<p class="count">' . format_plural($gallery->count, 'There is %count image in this gallery', 'There are %count images in this gallery') . "</p>\n";
      if (
$gallery->latest->changed) {
       
$content.= '<p class="last">'. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) . "</p>\n";
      }
     
$content.= "</li>\n";
    }
   
$content.= "</ul>\n";
  }

  if (
count($images)) {
   
$height += 5;
   
$content = 'this is the list of gallries<br><br>';
   
$content.= '<ul class="images">';
    foreach (
$images as $image) {
     
$content .= '<li';
      if (
$image->sticky) {
       
$content .= ' class="sticky"';
      }
     
$content .= ' style="height : '.$height .'px; width : '.$width.'px;"';
     
$content .= ">\n";
     
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
      if (
variable_get('image_teasers',0)){$content .= '<h3>'.l($image->title, 'node/'.$image->nid)."</h3>";}
      if (
theme_get_setting('toggle_node_info_' . $image->type)) {
       
$content .= '<div class="author">'. t('Posted by: %name', array('%name' => format_name($image))) . "</div>\n";
       
$content .= '<div class="date">'.format_date($image->created)."</div>\n";
      }
     
$content .= "</li>\n";
    }
   
$content.= "</ul>\n";
  }

  if (
$pager = theme('pager', NULL, variable_get('image_images_per_page', 6), 0)) {
   
$content.= $pager;
  }

  If (
count($images) + count($galleries) == 0) {
     
$content.= '<p class="count">' . format_plural(0, 'There is %count image in this gallery', 'There are %count images in this gallery') . "</p>\n";
  }

  print
$content;
?>

Dub

Just a short remark: For

scroogie - December 28, 2005 - 13:04

Just a short remark: For Drupal 4.7 you have to use check_markup() instead of check_output().

Working in 4.7?

vascopj - April 12, 2006 - 08:40

Did anyone get this to work in 4.7?

I tried but even if I changed the code it didn't seem to pick up the new image_gallery.tpl.php file.

thanks
S

wow...fastest drupal search

wtdtan - July 11, 2006 - 20:35

thanks for the tip scroogie. that made my image_gallery.tpl.php page work when i changed that function name.
and it didn't take me long to find the answer to my problem!

Also you should use

lenart - September 10, 2006 - 17:27

Also you should use theme_username($image) instead of format_name($image) on line 38.

problem when trying to edit, or delete an image node

aboros@drupal.org - January 11, 2006 - 15:40

hi,

i use drupal 4.6 and i am trying to customize my gallery [image_module] with your hints from the handbook.
it works almost perfect. 'just' i recieve the following error:

Cannot modify header information - headers already sent by (output started at /usr/home/keret/public_html/themes/leaf/template.php:13) in /usr/home/keret/public_html/includes/common.inc on line 192.

if i post new image, or edit, or delete some old ones. :(
what is wrong? where should i begin to search for the problem? i'm not a programmer, but a bit familiar with php...

:b

extra spaces..

Dublin Drupaller - January 11, 2006 - 17:41

That error is usually thrown up when there are extra spaces or lines at the end of a php file..i.e. after the ?> bit.

  1. Open your template.php or image_gallery.tpl.php file in a text editor
  2. Scroll to the bottom and delete any spaces or extra lines after the ?> at the end of the php
  3. Alternatively, just delete ?> from the last line in the file. I notice on other threads that it's not needed

Hope that helps.

Dub

CSS

falcon9xr - January 12, 2006 - 14:32

Don't forget to move over the contents of the image.css file to the CSS file of whatever theme you're using if you want the images to show up without the list marks and in rows instead of one huge column.

Also, if anyone is using the box_grey theme and is having trouble with getting images to take up the full length of the screen, try changing

#sidebar-right {
        border-left: 1px dotted #fff;
        background: #fff
}

to
#sidebar-right {
        float : right;
        border-left: 1px dotted #fff;
        background: #fff
}

I think in 4.7 this file is now called image_gallery.css

inthahousejamin - October 2, 2006 - 00:06

Ben W.

How to add Previous image and Next Image buttons

parisp - January 12, 2006 - 16:17

Thanks for the tips, this helped me wonderfully customize my gallery a bit.

However, what i would like to add is a buttons on the bottom of an image preview so users can use those buttons to browse throught the pictures of that specific gallery.

Any help or pointers on how to go about doing this will be much apreciated

thanks

I'm not really sure, but I'd

falcon9xr - January 13, 2006 - 20:17

I'm not really sure, but I'd suspect it would be somewhere in the image_display() function.

image_display() function

parisp - January 14, 2006 - 00:58

image_display() function handles the display of images in the gallery listing page, the gallery thumbnail images and the display of the image preview. basicle it handles any display of the image it self and not the layout where it apears.

after experementing a bit with the image.module code the function which handles the full view of an image when you click on it, which is the view i want to fiddle with and add previous,next image and back to gallery is the function image_view()

However i donno how about to change the gode to add that functionality or how to enable phptemplate to point to an image.tpl.php file to determine the layout without modifying the image.module code.

any help or pointers will be much aprecited

I think me too.

Ken Collins - January 19, 2006 - 18:01

I am trying to add a condition in the theme based on an $image's width. In this way I can wrap it with a span tag that constrain it to the right aspect ration and hence allows me to move an absolute positoined DIV based on this with CSS. What function() and code would I use to get this done? For instance, one of these?

<?php
   
if ($attr['width'] == '68') {
     
$content .= '<span class="img-vert">';
     
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
     
$content .= '</span>';
    }
    if (
$info['width'] == '90') {
     
$content .= '<span class="img-horiz">';
     
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
     
$content .= '</span>';
    }
?>

I'm wondering too if I should invoke image_get_info() in drupal's image core or go to the image.module functions like image_display() which uses the durpal core or maybe or _image_get_sizes()

try this..

Dublin Drupaller - January 19, 2006 - 18:28

Hi Ken,

Try this...

<?php
list($width, $height, $type, $attr) = getimagesize($image);?>

<?php $themewidth = ($width +100); /*adding 100 pixels to the width of the image */ ;?>

then use the $themewidth value to set the width of a DIV or whatever.

Dub

THANKS! - But No Luck or...

Ken Collins - January 19, 2006 - 19:06

I did not know where to put this. I tried placing it in the if (count($images)) part and uder the foreach statement of my image_gallery.tpl.php file, but id did not work. I could ever get any more than 100 for the $themewidth. If I put that $themewidth = ($width +100); at the top of my template file under the $size, $widht, $height variables, then $themewidth comes back of course to 190. Those variables at the top always return my image.module preferences and not the pixels dimensions of the image itself. Here is the structure of my (count ($images)) section now.

<?php
if (count($images)) {
 
$content.= "\n".'<div id="galleries">'."\n";
 
$content.= "\t".'<ul class="images">'."\n";
  foreach (
$images as $image) {
   
$content .= "\t"."\t"."<li";
    if (
$image->sticky) {
     
$content .= ' class="sticky"';
    }
   
$content .= ">\n";
   
$content .= '<h3>'.l($image->title, 'node/'.$image->nid)."</h3>";
    if {
// Condition 1
     
$content .= '<span class="img-horiz">';
     
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
     
$content .= '<span class="img-horiz">';
    }
    if {
// Condition 2
     
$content .= '<span class="img-vert">';
     
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
     
$content .= '<span class="img-vert">';
    }
    if (
theme_get_setting('toggle_node_info_' . $image->type)) {
     
$content .= '<div class="date">'.format_date($image->created, 'small')."</div>\n";
    }
   
$content .= "</li>\n";
  }
 
$content.= "</ul>\n";
 
$content.= "</div>\n";
}
?>

okay

Dublin Drupaller - January 19, 2006 - 19:21

sorry ken..thought you wanted the snippet for a node-image.tpl.php file.

I'll look into it...it might be the

variable_get($thumbsize) variable that is needed for the gallery pages.

Am busy right now but will look into it later

Dub

Sharing what I found out...

Ken Collins - January 22, 2006 - 16:28

I was able to find out the width of the image being used on the galleries page by setting these two vars.

<?php
$var1
= image_get_info(file_create_path($gallery->latest->images['thumbnail']));
$var2 = $var1[width];
?>

Likewise, I was able to get the width of the thumbnail images used on the images page using these two vars.

<?php
$var1
= image_get_info(file_create_path($image->images['thumbnail']));
$var2 = $var1[width];
?>

Gallery Description

dhassan - February 6, 2007 - 13:35

I have the module working in 4.7, and even modified it to display full-size (250x250px) images:
http://www.wtp-corp.com/?q=image/tid/18

It's imperative that these gallery pages display the gallery description at the top, and I've been trying to find a way to use the image_gallery.tpl.php file to do this. I tried copying this line to the image section:

$content.= ''. check_markup($gallery->description) ."\n";

No luck, though I did figure out how to modify this tag to display the image text body :)

Anyway, can anyone suggest a way to display the gallery description with the image gallery?

Thanks.

Gallery Description solved

Deciphered - May 24, 2007 - 03:07

Hi dhassan,

I've been trying to figure this out as well, and I have figured it out.

Locate the following lines:

  if (count($images)) {
    $height += 5;

and add the following lines after it:

    foreach ($images[0]->taxonomy as $taxonomy) {
      $content.= '<div class="description">'. check_markup($taxonomy->description) ."</div>\n";
    }

Hope this helps.

Gallery description above thumbnails

linkovitch - April 13, 2008 - 15:39

Hello, I'm trying to get descriptions to appear above the thumbnails. I have image_gallery.tpl.php in place and working, but I cannot seem to get anything to display using your code or any other code from image_gallery.module. I'm on 5.7 and image_gallery.module v 1.5.2.14.

I know it is just a matter of the correct php snippet in the correct place in image_gallery.tpl.php

THANKS!

Adding text to thumbs...

michellex - March 1, 2006 - 23:10

Do you guys know if there's a way to add some text to the thumbnails?

Also... my next page stuff doesn't work... http://www.steelveils.com/?q=image

I am trying to text below

underpressure - November 21, 2006 - 15:21

I am trying to text below thumbnails as they are in the default layout, has anyone firgured out how to do this?
--------------------->
underpressure
http://ravalonline.com

This is available in image_gallery.module

harrisben - November 21, 2006 - 21:02

That file is found in /modules/image/contrib/image_gallery

If you open that file in a text editor and find the section that says 'Theme a gallery', that's it. Everything there determines how the gallery looks (along with image_gallery.css).

If you do manage to get this working I'd love to hear how you did it, because I've had no success.

Really excited I've got it looking pretty now but....

michellex - March 5, 2006 - 03:53

Some questions: In order to get a description in with the thumbnails, I had to hardcode it in, but I forgot that it would need to be different for different "albums". Is there a way to write an if statement or something so it will change?
(the description with the prints all can be the same, but not with collections, see link)

Also, the next and previous links don't work. Any ideas how to fix this?

And lastly... is there a way to limit how many images are shown on the page? I tried adjusting 'image_images_per_page', 6 (the 6 there) but that didn't do anything.

Here's the reference: http://www.steelveils.com/?q=image
(warning: artistic nudity)

If I get all this working, I'm seriously considering writing a tutorial. :)

thanks,
~M

www.steelveils.com

So elusive...

michellex - March 5, 2006 - 16:09

I figured out the next & previous issue. Apparently there is a patch that needs to happen for people on 4.6.4 - http://drupal.org/node/39566
.... Had no idea...

On to the next thing.
~

www.steelveils.com

It's a nice pagination at

hip - May 21, 2006 - 18:09

It's a nice pagination at the bottom of the pict galleries (at http://www.steelveils.com/?q=image). That's set at template.php, I guess. How do you achieve it? Is there any tutorial I've missed about paginating results?

In fact, I'm making use of Acid for the image galleries. Everything but the pagination/navigation system between big-sized pictures runs smoothly. Pagination has a 'First-previous-next-Last' scheme but is not working. It's showing some weird links. So I'd like to do/redo the pagination system to format it my way and to get to understand it, in order to be able to find wether the problem relies on Acid or template.php.

Thanx for any help.
hip

Myself, Don't worry about my

hip - May 21, 2006 - 20:43

Myself,

Don't worry about my above post. The pagination problem in Acidfree galleries was due to my client's horrible host (Arsys) misconfiguration. They're still on mySQL 3. I've applied the right patch (at http://drupal.org/node/41025) and everything is up and running.

Besides I don't have the time nor the strength to do no bettering on this job.

Thanx anyway,
hip

Can I do this with the chameleon theme?

yvelle - April 17, 2006 - 22:05

Normally, I would just add a function as such:

function themename_image_gallery($galleries, $images) {

and this would override the theme call in the module. This is how I would do it to override theme_node and theme_block. But it isn't working for the image module. Is there something different about theming modules?

nevermind

yvelle - April 17, 2006 - 22:08

That is exactly how it works. I simply forgot to upload the changes to my server :-p

Has anybody got a working

jeforma - May 1, 2006 - 23:50

Has anybody got a working version of this for Drupal 4.7?

Visit GameBGS.com for all your gaming needs.

Ditto

jfriesen - June 19, 2006 - 04:11

I, too, would love to see some help for 4.7

"Reality is what trips you up when you walk around with your eyes closed." F. Paul Wilson

have you test in 4.7?

yvelle - June 25, 2006 - 22:38

I'm using 4.7 and didn't have a problem overriding the theme as i suggested above.

I'm looking for this too...

gmak - July 10, 2006 - 19:35

I've got the gallery 'list' page (what appears when you click on a link like "mysite.com/image") theming according the code provided. However, when I click on a link to a specific gallery I get a blank page. There is no error generated in either the Drupal logs or the server logs. Just a big white blank page in the browser.

Has anyone managed to theme the image.module in 4.7? If so, I would really appreciate a walk-thru of your process.

Make minor adjustments for 4.7

maybourne - July 14, 2006 - 13:16

If you have an undefined function error or all your thumbnails are in one column..

In template.php:

<?php
/**
* Catch the theme_image_gallery function, redirect through the template api
* and point Drupal to your image_gallery.tpl.php file to determine the layout
* of your image gallery pages.
*/
function phptemplate_image_gallery($galleries, $images) {
 
// Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
  // will be assigned within your template.
  /* potential need for other code to extract field info */
  
drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'image_gallery') .'/image_gallery.css'));
return
_phptemplate_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
  }
?>

In image_gallery.tpl.php:

<?php
 
// We'll add height to keep thumbnails lined up.
 
$size = _image_get_dimensions('thumbnail');
 
$width = $size['width'];
 
$height = $size['height'];

 
$content = '';
  if (
count($galleries)) {
   
$content.= '<ul class="galleries">';
    foreach (
$galleries as $gallery) {
     
$content .= '<li style="height : '.$height .'px">';
      if (
$gallery->count)
       
$content.= l(image_display($gallery->latest, 'thumbnail'), 'image/tid/'.$gallery->tid, array(), NULL, NULL, FALSE, TRUE);
     
$content.= "<h3>".l($gallery->name, 'image/tid/'.$gallery->tid) . "</h3>\n";
     
$content.= '<div class="description">'. check_markup($gallery->description) ."</div>\n";
     
$content.= '<p class="count">' . format_plural($gallery->count, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "</p>\n";
      if (
$gallery->latest->changed) {
       
$content.= '<p class="last">'. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) . "</p>\n";
      }
     
$content.= "</li>\n";
    }
   
$content.= "</ul>\n";
  }

  if (
count($images)) {
   
$height += 75;
   
$content.= '<ul class="images">';
    foreach (
$images as $image) {
     
$content .= '<li';
      if (
$image->sticky) {
       
$content .= ' class="sticky"';
      }
     
$content .= ' style="height : '.$height .'px; width : '.$width.'px;"';
     
$content .= ">\n";
     
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
     
$content .= '<h3>'.l($image->title, 'node/'.$image->nid)."</h3>";
      if (
theme_get_setting('toggle_node_info_' . $image->type)) {
       
$content .= '<div class="author">'. t('Posted by: %name', array('%name' => theme('username', $image))) . "</div>\n";
        if (
$image->created > 0) {
         
$content .= '<div class="date">'.format_date($image->created)."</div>\n";
        }
      }
     
$content .= "</li>\n";
    }
   
$content.= "</ul>\n";
  }

  if (
$pager = theme('pager', NULL, variable_get('image_images_per_page', 6), 0)) {
   
$content.= $pager;
  }

  If (
count($images) + count($galleries) == 0) {
     
$content.= '<p class="count">' . format_plural(0, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "</p>\n";
  }

  print
$content;
?>

Thanks

mirko - August 22, 2006 - 12:16

Thanks!!!! Works fine now. Maybe this code should be added in the handbook?

removing authoring info

okellhammer - August 31, 2006 - 02:15

I'm not a PHP coder and am a total Drupal newbie, (more used to operating in plone)

I want to turn *off* the authoring information that is being displayed in the image gallery of my drupal 4.7 site. I've tried uploading the above PHP scripts to my themes/bluemarine directory and it simply breaks the gallery, i.e. images won't display.

I get this error message:

"PHPTemplate was instructed to override the image_gallery theme function, but no valid template file was found."

The problem seems to be in the template.php file. When I remove it from the directory, the gallery loads fine, except (sigh) with that pesky authoring information under every image.

Can anyone help me?

Remove authoring info

Minty - September 27, 2006 - 15:10

This may be too simple for what you are doing, but you can normally remove authoring information without code amendment by going into:

>administer>themes>configure.
Select default to apply your settings to all themes, or select a particular theme.
There are selection buttons for show/hide authoring information for each content type.

Drupal developers have already done the work!

Gallery theming

stoltoguzzi - May 5, 2006 - 08:06

Opening the gallery using something like image/29 where 29 is the id of the main gallery
will produce some kind of teaser list.

what I would like to have is a list in the form:

Gallery1
image1 image2 image3

Gallery2
image1 image 2

Gallery3
...

can somebody help for the first steps

pop-up

kvarnelis - June 9, 2006 - 20:38

some images are too big for my theme. i'd like them to pop up as separate windows. any idea how to code that? i am using 4.7.

Look at the lightbox2 module

sepeck - June 9, 2006 - 21:14

Look at the lightbox2 module as a starting point..

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

Change an image Alt tag

barrygirsh - August 3, 2006 - 14:42

I am trying to change an image's Alt tag to o Node Word (meta tag). Can't seem to find where the Alt tags are implemented. Is it in the 'image.module' file? Any help would be gratefully appreciated.

I don't understand what I'm doing wrong

harrisben - November 14, 2006 - 03:09

I'm using 4.7.4 and want to avoid modifying image_gallery.module so have done the following:

Added code to template.php:

/**
* Catch the theme_image_gallery function, redirect through the template api
* and point Drupal to your image_gallery.tpl.php file to determine the layout
* of your image gallery pages.
*/
function phptemplate_image_gallery($galleries, $images) {
  // Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
  // will be assigned within your template.
  /* potential need for other code to extract field info */
return _phptemplate_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
  }

Created new image_gallery.tpl.php and added code:

<?php
/**
* Theme a gallery page
*/
  // We'll add height to keep thumbnails lined up.
 
$size = _image_get_dimensions('thumbnail');
 
$width = $size['width'];
 
$height = $size['height'];

 
$content = '';
  if (
count($galleries)) {
   
$content.= '<ul class="galleries">';
    foreach (
$galleries as $gallery) {
     
// $content .= '<li style="height : '.$height .'px">';
     
if ($gallery->count)
       
$content.= l(image_display($gallery->latest, 'thumbnail'), 'image/tid/'.$gallery->tid, array(), NULL, NULL, FALSE, TRUE);
     
$content.= "<h3>".l($gallery->name, 'image/tid/'.$gallery->tid) . "</h3>\n";
     
$content.= '<div class="description">'. check_markup($gallery->description) ."</div>\n";
     
$content.= '<p class="count">' . format_plural($gallery->count, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "</p>\n";
      if (
$gallery->latest->changed) {
       
$content.= '<p class="last">'. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) . "</p>\n";
      }
     
$content.= "</li>\n";
    }
   
$content.= "</ul>\n";
  }

  if (
count($images)) {
   
$height += 75;
   
$content.= '<ul class="images">';
    foreach (
$images as $image) {
     
$content .= '<li';
      if (
$image->sticky) {
       
$content .= ' class="sticky"';
      }
     
$content .= ' style="height : '.$height .'px; width : '.$width.'px;"';
     
$content .= ">\n";
     
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
     
$content .= '<br />'.l($image->title, 'node/'.$image->nid);
      if (
theme_get_setting('toggle_node_info_' . $image->type)) {
       
$content .= '<div class="author">'. t('Posted by: %name', array('%name' => theme('username', $image))) . "</div>\n";
        if (
$image->created > 0) {
         
$content .= '<div class="date">'.format_date($image->created)."</div>\n";
        }
      }
     
$content .= "</li>\n";
    }
   
$content.= "</ul>\n";
  }

  if (
$pager = theme('pager', NULL, variable_get('image_images_per_page', 6), 0)) {
   
$content.= $pager;
  }

  If (
count($images) + count($galleries) == 0) {
     
$content.= '<p class="count">' . format_plural(0, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "</p>\n";
  }

  return
$content;
?>

When I navigate to my galleries, nothing displays though. Can anyone tell me what I'm doing wrong?

How frustrating

harrisben - November 17, 2006 - 05:23

Nothing I do, even duplicating what someone else says works for them in 4.7, works. I don't want to edit the module directly, can anyone help?

I realize this is 4 months old, but...

keathmilligan - February 12, 2007 - 04:17

I know this is really old and I'm sure the OP found a solution, but in case anyone else runs into this issue...

You need to replace the "return $content" at the end with "print $content". It's an easy error to make if you start by copying the original implementation from the image gallery module.

Reverse order?

elv - January 3, 2007 - 19:56

I've tried to display the images in chronological order, but couldn't find a way... Is there a good way (via template files) to modify the node list order?

array_reverse

zigazou - January 11, 2007 - 10:29

The image_gallery.tpl.php recieves an array ($images), then you can use the array_reverse function from PHP to put it in order.

<?php
  $images
=array_reverse($images);
?>

That's what I use and it works fine, except if you use the sticky flag on your image nodes.

If you use the sticky flags on image nodes, and still wants to force a chronological order, you need to :

  • get the key list (array_keys($images))
  • do a query like SELECT nid FROM node WHERE nid IN (imageskeys) ORDER BY sticky DESC, created ASC
  • you now have the nids in the wanted order, just loop over this list instead of over $images

Good idea but...

elv - January 16, 2007 - 19:16

Thanks for the tip, but it seems it doesn't work as expected, it reverses the order of the images on a given page, but not the order of ALL the images.
Say, I have 6 nodes per page, and a total of 9 nodes to display.
Without any modification they will be listed on two pages as:
9 8 7 6 5 4
3 2 1
And with the array_reverse as:
4 5 6 7 8 9
1 2 3
And I'm trying to do this:
1 2 3 4 5 6
7 8 9

Maybe I could use it at a higher level? But I wonder if it can be done in a theme file.

Maybe using views

patchak - January 16, 2007 - 19:34

Maybe using views integration with images and the grid bonus view to redirect your taxonomy links to your custom view?

Oh!

elv - January 16, 2007 - 20:59

"redirect your taxonomy links to your custom view"

Looks like I still have things to learn with views... Do you mean it can be done automatically for taxonomy terms? I'll investigate tonight. Thx!

hey,

patchak - January 16, 2007 - 21:04

hey,

http://www.lullabot.com/articles/how_to_build_flickr_in_drupal

On this article, in the section 3 Theme o rama, you'll find details about how to actually redirect taxonomy links to a custom view. I'm actually planning to use it (redirecting image links to custom gallery) myself in a project in the next two weeks, so I'll keep you posted on what I find and vice versa I hope ;)

cya

Views arguments

elv - January 17, 2007 - 03:58

OK I found how to "redirect" the taxonomies to a view, using the "arguments" settings on "Taxonomy term name".
Works well with node dates, so I can set the order to ascending or descending. Great!

Now I also need my users to reorder nodes manually if they want to. The nodes would then be ordered by "order number" then by date.
So I created a Vocabulary named "order", with numbers as terms: 1,2,3, etc.
It won't work, Views seems to use the term weights only, whereas the help text says that "This will sort nodes by taxonomy weight and name". Or more likely, I misunderstood that line ;)

I could use node_weight module, but the weights go from -x to +x (with a max of 40) when I'd like a range of something like 0 to 100.

well... can't help you on

patchak - January 17, 2007 - 13:26

well... can't help you on that one sorry!

Comment link under thumbnail

ckjian - August 4, 2007 - 15:29

I've followed the instructions at http://drupal.org/node/41257 for version 5. I managed to theme the image gallery page. However I would like to a comment link right below each of the thumbnails. The base_url won't print. Please help me check out the code. See below:

<?php
$content
.= '<br /><a href="'.$base_path.'/comment/reply/'.$image->nid.'#comment-form" class="comment-link">Add comment ('.$image->comment_count.')</a>';
?>

The problem I'm facing now is that I'm not able to get the base_url to be inserted to the url. I know that I can type in the url manual but I will be better if can insert the $base_path into the url.

Any help plz?

This doesn't work for me on

denizengt - August 14, 2007 - 00:24

This doesn't work for me on 5.2, I get this error:

Fatal error: Call to undefined function _image_get_dimensions() in /Applications/xampp/xamppfiles/htdocs/site/themes/new_theme/image_gallery.tpl.php on line 204

me too

jphelan - August 15, 2007 - 19:40

I get the same error as denizengt but on line 2

A fix for _image_get_dimensions() not defined

astroboy - August 16, 2007 - 10:24

quite simple, but found it in another thread :

replace

<?php
_image_get_dimensions
()
?>

by

<?php
_image_get_sizes
()
?>

Two things need to be changed on the image_gallery.tpl.php file

rad1964 - September 13, 2007 - 20:13

In order for the image gallery formatting template to work for me:

Line #2

Change: $size = _image_get_dimensions('thumbnail'); [to] $size = _image_get_sizes('thumbnail');

Line #38

Change: format_name ($image) [to] theme_username($image)

And the new formatting changes now work.. This is in Drupal V. 5.2 .

RAD

Thanks

jazbek - September 23, 2007 - 01:24

Thanks RAD that sorted me out. Appreciate your help.

Drupal 5.2 - Need to change @name to !name in Line 38

Keyz - September 24, 2007 - 03:04

In my case, I had to make 2 additional small changes to image_gallery.tpl.php in order to get it working... I wanted to mention them here in case anyone else runs into the same thing.
My configuration includes: Drupal 5.2 and Image 5.x-1.5

When I added the Drupal 5 code from http://drupal.org/node/41257 and applied the changes to Lines 2 and 38 mentioned above, I loaded mysite.com/image/tid/1 and the Posted by: user name portion's html tags were printing out on the page and the link didn't work. I checked the similar line in the current image_gallery.module file, and it seems the parts in Line 38 that says @name needs to be changed to !name ... just change both instances of @name in Line 38 and it should work.

Alternately, if you prefer not to display the "Po