I have an image field for my terms and a view of those terms. I can display the image's file name in a view, but how can I show the actual image?

Thanks

Comments

b-prod’s picture

You can use for example the "rewrite field" option:
<img src="[base_url if necessary]/[path to the file folder]/[view token for the image URL]" alt="[view token for the node title e.g.]" />
It is also possible for example to use an imagecache path for auto resizing etc.

anrikun’s picture

I have an image field for my terms and a view of those terms. I can display the image's file name in a view

Really?
I don't see any "Image" type in Term fields.
And when using File as type, all I can display is file FIDs, not file names.

b-prod’s picture

Version: 6.x-1.9 » 6.x-2.x-dev
Category: support » feature

Some work has to be done on the file/image widget on the new 2.x DEV version.

b-prod’s picture

Status: Active » Closed (duplicate)
freeform.steph’s picture

If you have views custom field installed (http://drupal.org/project/views_customfield) you can use php to display your image. Add the term field as normal, but set it to not display. Then add a new php field with the following:

$the_img = field_file_load($data->term_fields_term_YOURFIELDNAME_fid);
print theme_image($the_img['filepath'], $alt = '', $title = '', $attributes = NULL, $getsize = TRUE);

If you also add a hidden field for the title than you can populate the alt and title attributes.

Or, if you have imagecache installed, you can use a preset like so:

$the_img = field_file_load($data->term_fields_term_YOURFIELDNAME_fid);
print theme_imagecache('YOUR_PRESET_NAME',$the_img['filepath']);