Please consider adding support for Taxonomy Image.

This is from the module's description:

The taxonomy_image module allows site administrators to associate images with taxonomy terms. With the association created, an admin can then make a call to taxonomy_image_display() from their theme or other PHP code to display the appropriate image.

Comments

klonos’s picture

adding the following code did it:

if (module_exists("taxonomy_image")) {
		$output .= taxonomy_image_display($term->tid);
}

This displays the corresponding image next to each term.

traceelements’s picture

Where do I add this code?

klonos’s picture

well... it goes in the taxonomy_blocks.module file. That's the only thing for sure ;)

Where in that file you say? ... I only can give you some clues because it seems I've modified mine to such an extend that it now displays items in a table instead of a list + other custom things I needed.

As it is now, the module prints a list of html links pointing to the term page, like so:

<a href="path_to_term"></a>

I wanted it like so:

<a class="some_class_here" href="path_to_term"><img src="taxonomy_image_of_the_term"/></a><code>

1. Search for this line of code: <code>$output .= l(t($term->name), $path);

. This prints the links of your list (the l() function is documented here: http://api.drupal.org/api/function/l)

I couldn't figure out how to change it to display an image with a link back in February when I took a shot at it. There seems to be a discussion about it going on here: http://drupal.org/node/105249

2. ...so I added this code before:

        $output .= '<a class="dock-item" href="' . $path . '">';
        $output .= '';
        
        if (module_exists("taxonomy_image")) {
          $output .= taxonomy_image_display($term->tid);
          //$output .= taxonomy_image_url($term->tid);
          //$output .= taxonomy_image_get_url($term->tid);
        }
        
        $output .= '</a>';

You can tell I left some work to be done here because of the empty $output .= ''; (I probably wanted to add an alt attribute or something here). You can also see the two commented out lines about taxonomy_image_url and taxonomy_image_get_url. I cannot remember what I needed with these.

Anyways, the code above writes a html tag with an image.

1st line opens the tag and adds a class to it so I can customize it with css later on.
2nd line... as I said I cannot remember why I wrote it. It does nothing.
3rd line checks if the Taxonomy Image module is installed.
4th line appends the taxonomy term's image to the output variable.
5th & 6th line again I cannot remember what I needed to do with them
7th line closes the tag

I cannot remember if it worked or not. I think I gave up on the idea. I am not sure.

Good luck with that.

traceelements’s picture

Oh my god, it worked! Thank you so, so much!

This is what I ended up using, because I wanted the image followed by the text link:

       $output .= '<a class="dock-item" href="' . $path . '">';
       
        if (module_exists("taxonomy_image")) {
          $output .= taxonomy_image_display($term->tid);
        }
		
		$output .= l(t($term->name), $path);
       
        $output .= '</a>';
klonos’s picture

I'm glad you're glad ;)

klonos’s picture

btw, the class="dock-item" part is to add a class that will help you with css styling the image. Feel free to change it as desired.