views:

26

answers:

3

I'm creating a view with images, videos, audio and documents (books) and I like to shown a picture of each of them in a carousel.

Everything works nicely with images and videos as far as we added a image-thumbnail (image filefield) to their CCK but we like to show a default image for audio and documents without changing the original CCK. Is it possible with imagecache (may be with imagecache_custom_code or views_custom_php) or we need to look for a different approach?

Thanks for your help, m.

A: 

You are able to do this from two places.

First, you can go into Display Fields part of the CCK content type settings and change its default display in the teaser and node view. You will be given all the current imagecache presets as sizing options for display.

Second, you can also change the output as part of Views. Adding the image as a Field to show will give you the same set of preset options.

Kevin
Thanks for your time but this is not what I'm asking for.Both solutions require a change in my book and audio content types to add an specific cck field (image filefield) with an image and this is exactly what I'm trying to avoid.Any further ideas?
Marc Bria
It is what you are asking for though? Go into your View, and click on the Field that shows the thumbnail. In its options, there is a select list that will allow you to pick an imagecache preset to display the thumbnail as in that view.
Kevin
A: 

I'm going to say something very similar to Kevin above but I think it's the solution your looking for. To understand the problem:

  • you have 3 content types, two have thumbnails that you set individually
  • for the third you would like to have a default image displayed but not have to set it

I think you should still use a cck field.

I might be mis-understanding your issue though.

openist
Thanks for your both for your help.> I think you should still use a cck field.You took a good picture of the scenario, but this is exactly the point of what I was trying to avoid. :-)I don't want to use a cck field for books and I don't want to hide it with hook_form_alter.I finally found a solution that didn't require adding extra CCK-fields to my "non-image" content types (audio and text)."Views custom field" (http://drupal.org/project/views_customfield) allows you to add a PHP-processed-field to your view.So you can filter by content type and apply imagecache or imageapi code.
Marc Bria
A: 

Thanks for your both for your help.

I think you should still use a cck field. You took a good picture of the scenario, but this is exactly the point of what I was trying to avoid. :-)

I don't want to use a cck field for books and I don't want to hide it with hook_form_alter.

I think I finally found a solution that didn't require adding extra CCK-fields to my "non-image" content types (audio and text).

There is a module called "Views custom field" (drupal.org/project/views_customfield) that allows you to add a PHP-processed-field to your view, so you can filter by content type and apply imagecache or imageapi code

$node=node_load($data->nid);
$img_path=drupal_get_path("module", "gt_medias") . "/images";

switch ($node->type) {
  case "gt_video":
    $img_path = $node->field_gt_thumbnail[0][filepath];
  break;
  case "book":
    $img_path .= "/bookDefault.jpg";
  break;
  case "gt_audio":
    $img_path .="/audioDefault.png";
  break;
  case "pingv_image":
    $img_path = $node->field_pingv_image[0][filepath];
  break;
}

$imgcache_url = imagecache_create_url('gt_medias_video_346', $img_path);

$output .= '<img src="'. $imgcache_url .'" ' />';
return ($output);

Where "gt_medias_video_346" is the name of my imagecache preset.

Once again, thanks you both for your help,

m.

Marc Bria

related questions