欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

得到imagecache 的图像路径 图像裁切

shiping1 的头像
<?php print imagecache_create_url('middle_210_118', $node->field_shiping_image[0]['filepath']); ?>
这个有大用  middle_210_118是预设的 $node->field_shiping_image[0]['filepath']是本来字段的路径
<?php
//下面是打印的img的路径
  print imagecache_create_url('imagecache_name', $node->field_name[0]['filepath']);
?>


   //下面的打印的img标签
  print theme('imagecache', 'middle_210_118', $node->field_shiping_image[0]['filepath']);


  middle_210_118是预设的





Drupal - Print path to image cache image?

I have an image added as a CCK field. In a node tpl file how can I print the url to the image cache image?

I need to add the image cache image as an inline style background image, to a div in my node tpl file.

The Content Template module gives me a few options but not quite what I need. It allows me to print the image cache image as html content, but doenst give me the file path to use as an inline style. It also allows me to print the image file path, but only for the full image not the image cache version.

Content Template does give me the name of the image cache preset, so I can manually write this: my-site.com/sites/default/files/imagecache/preset-name/file-name-token

However im thinking their must be a cleaner way? Thanks

share|improve this question
 add comment
up vote 1 down vote accepted

Here you have!

theme('imagecache', 'name_of_your_preset', $item['filepath']);
share|improve this answer
 add comment

This worked for me. The key was "imagecache_create_url".

<?php
  print imagecache_create_url('imagecache_name', $node->field_name[0]['filepath']);
?>

来自 http://stackoverflow.com/questions/6562807/drupal-print-path-to-image-cache-image
普通分类: