跳至内容
Python 俱乐部
用户工具
登录
站点工具
搜索
工具
显示页面
修订记录
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
drupal:script:imagefield-link
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
====== Drupal 修改图片链接 ====== ===== imagefield链接到指定网页 ===== 修改了 imagefield 中到原始图片的链接,实现到指定链接的功能。 修改文件 imagefield/imagefield_formatter.inc <code php> function theme_imagefield_formatter_image_imagelink($element) { // Inside a view $element may contain null data. In that case, just return. if (empty($element['#item']['fid'])) { return ''; } $item = $element['#item']; $original_image_url = file_create_url($item['filepath']); $class = 'imagefield imagefield-imagelink imagefield-'. $element['#field_name']; # return l($imagetag, $original_image_url, array('attributes' => array('class' => $class), 'html' => TRUE)); $imagetag = theme('imagefield_formatter_image_plain', $element); # drupal_set_message( "<pre>" . print_r($imagetag, true) . "</pre>"); $node = $element['#node']; return l($imagetag, $node->field_url[0]["value"], array('attributes' => a rray('class' => $class), 'html' => TRUE)); } </code> 主要加了下面两行: <code php> $node = $element['#node']; return l($imagetag, $node->field_url[0]["value"], array('attributes' => a rray('class' => $class), 'html' => TRUE)); </code> ===== imagecache图片链接 ===== 修改文件 imagecache/imagecache.module <code php> function theme_imagecache_formatter_imagelink($element) { // Inside a view $element may contain NULL data. In that case, just return. if (empty($element['#item']['fid'])) { return ''; } // Extract the preset name from the formatter name. $presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); $style = 'imagelink'; $item = $element['#item']; $item['data']['alt'] = isset($item['data']['alt']) ? $item['data']['alt'] : ''; $item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL; $imagetag = theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title']); $path = file_create_url($item['filepath']); $class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element['#formatter']}"; $node = $element['#node']; #drupal_set_message ( "<pre>" . $class ."</pre>" ); return l($imagetag, $node->field_url[0]["value"], array('attributes' =>array('class' => $class, "target" => "_blank"), 'html' => TRUE)); #return l($imagetag, $path, array('attributes' => array('class' => $class), 'html' => TRUE)); } </code>
drupal/script/imagefield-link.txt
· 最后更改: 2010/12/08 07:27 (外部编辑)
页面工具
显示页面
修订记录
反向链接
回到顶部