Displaying all terms' images in a view
borfast - May 24, 2009 - 15:30
| Project: | Taxonomy Image |
| Version: | 6.x-1.6 |
| Component: | Views |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | different, display, duplicate, image, taxonomy, taxonomy image, term image, tid, views, vocabulary |
Description
Hello.
I have a view that outputs a list of nodes and each node may have more than one taxonomy term, even from different vocabularies - how can I output all of these, or select from which vocabulary I want the images to be displayed?
Thanks.

#1
Hello,
Same need here (with the same version, 6x-1.6). I'd like to use Taxonomy image as a way to display various little black and white logos (a taxonomy image previously associated to a term) near a photo and some text in a view. But I can only display one logo or twice the same one (please see screenshot) while adding another "Taxonomy: Term Image" field. The tid seems to call always the same term, but obviously, I would like to show different thumbnails (from different vocabularies or from a single "thumbnails" vocabulary if the former is impossible) in a single "teaser".
This may comes from the Views module above all, but we were asked to ask you first, so...
#2
Anyone?
#3
ErwanF, I ended up adding a function to template.php to (sort of) achieve what I wanted.
The function takes the output of the "Taxonomy: all terms" views field, which is basically an HTML list of links to each taxonomy term. I break them apart and replace the linked text with the desired image.
Far from perfect, since this should belong in the module itself, but at least it works.
Note: "Tamarind" is the name of the theme I'm working with.
function tamarind_tax_image($subject) {
$links = explode(', ', $subject);
$pattern = '/taxonomy\/term\/(\d)/';
$result = array();
foreach($links as $link) {
preg_match($pattern, $link, $matches);
$image = taxonomy_image_get_object($matches[1]);
if ($image) {
$result[] = l($image->img, $image->term, array('html' => true));
}
}
return $result;
}
#4
Thanks a lot for the "tip", borfast, I'll try that.
#5
Please could you explain? How do replace the term name by its image? At the time of writing, I can only display the terme name...
#6
I didn't manage to make this working. So sad...
#7
ErwanF, sorry, I had not yet seen your request for an explanation.
When I say
I mean that I have a "All terms" field, which prints something like
<a href="taxonomy/term/5">Books</a>, <a href="taxonomy/term/6">Cars<a>, <a href="taxonomy/term/7">Houses</a>and I break it apart on the commas, which yields an array of individual links, which I then treat as necessary.The commas are separating the links because that's how I configured the field.