开发者

Imagecache for non image CCKs?

开发者 https://www.devze.com 2023-01-02 19:37 出处:网络
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.

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 l开发者_JAVA百科ook for a different approach?

Thanks for your help, m.


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.


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.

  • Add a cck field for the image
  • Set a default image for that cck field (http://screencast.com/t/YzA0OWY4Mz)
  • Set your imagecache from the display tab
  • Hide the cck field from node edit for using http://drupal.org/project/formfilter, http://drupal.org/project/cck_field_perms, or hook_form

I might be mis-understanding your issue though.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消