imagefield

Drupal7 imagefield_extended 的代用品 replacement for imagefield_extended

D6 的 imagefield_extended是我一個常用的模組,
可以將數個文字欄位加到 image 上,
當 imagefield 本身是 unlimited 的時候很有用

但顯然這不是 D7 的做法
D7 的做法是原生的將多個欄位組合, 而不只是 image 和 text
可以 image 和 email, options 等等
http://drupal.org/project/field_collection

而現在的 dev version 有一個 bug,
要支持 imagefield 便要使用以下的 patch
http://drupal.org/node/1187010#comment-4947330

操作上,
先到 structure define "field-collections"
便可以建立一個 "包含數個 field 的 field"
然後像一般的欄位到 content type 的頁面設定便可以
Widget 選 "embedded"

從 fid 提取上傳檔案的資料 Get file info from fid: Drupal6

Get views result anywhere use:

<?php
views_get_view_result
($view_name,$display_name);
?>

EDIT 2011-01-10: or use $view->preview()

But it only return fid in imagefield

To get to filepath and other info, you have to:

<?php
$file
= field_file_load($node->website_logo_fid);
$output .= "<p><img src=\"".$file['filepath']."\" alt=\"\" /></p>";
?>

source: http://snipplr.com/view/26812/drupal--get-the-image-path-of-a-cck-field-...

result:

last, output image tag:

<?php
echo theme_image($path,$alt,$title);
?>

http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_image/6

Render Imagecached image through PHP

<?php
echo theme('imagecache', $preset, $imagepath, $alt, $image_title)
?>

Can be use in node.tpl.php
在 node.tpl.php 內可用
$preset is the machine name in imagecache UI
其中 $preset 是imagecache profile 的 machine name

ref: http://drupal.org/node/163561