THEME_preprocess_image 和 THEME_image 之间的区别?
Difference between THEME_preprocess_image and THEME_image ?
Drupal 只能放入 template.php 这两个函数有什么区别?
function THEME_preprocess_image(&$variables) {
// something
}
function THEME_image($variables) {
// something
}
function theme_image 渲染可渲染数组的 HTML 输出。
THEME_preprocess_image
我相信,它的正确名称是 template_preprocess_HOOK
,它在主题函数之前在 theme()
内部调用,例如。 THEME_image
请考虑这里的用例:
// 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);
如果要更改图像的某些属性,请执行以下操作:
function mytheme_preprocess_image($vars) {
// Do the changes, before it's rendered.
}
Drupal 只能放入 template.php 这两个函数有什么区别?
function THEME_preprocess_image(&$variables) {
// something
}
function THEME_image($variables) {
// something
}
function theme_image 渲染可渲染数组的 HTML 输出。
THEME_preprocess_image
我相信,它的正确名称是 template_preprocess_HOOK
,它在主题函数之前在 theme()
内部调用,例如。 THEME_image
请考虑这里的用例:
// 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);
如果要更改图像的某些属性,请执行以下操作:
function mytheme_preprocess_image($vars) {
// Do the changes, before it's rendered.
}