首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >THEME_preprocess_image与THEME_image的差异?

THEME_preprocess_image与THEME_image的差异?
EN

Stack Overflow用户
提问于 2015-08-19 16:25:28
回答 1查看 306关注 0票数 1

这两个函数在Drupal中只能放入template.php之间有什么区别?

代码语言:javascript
复制
function THEME_preprocess_image(&$variables) {
    // something
}

function THEME_image($variables) {
    // something
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-08 14:34:05

图像呈现可呈现数组的HTML。

THEME_preprocess_image

我相信,正确的名称是template_preprocess_HOOK,它在主题函数之前在theme()内部被调用。THEME_image

请考虑这里的用例:

代码语言:javascript
复制
// In custom.module     
$variables = array( 
  'path' => 'path/to/img.jpg', 
  'alt' => 'Test alt',
  'title' => 'Test title',
  'width' => '50%',
  'height' => '50%',
  'attributes' => array('class' => 'some-img', 'id' => 'my-img'),
  );
$img = theme('image', $variables);

如果要更改图像的某些属性,请执行以下操作:

代码语言:javascript
复制
function mytheme_preprocess_image($vars) {
    // Do the changes, before it's rendered.
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32100917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档