这两个函数在Drupal中只能放入template.php之间有什么区别?
function THEME_preprocess_image(&$variables) {
// something
}
function THEME_image($variables) {
// something
}发布于 2015-09-08 14:34:05
图像呈现可呈现数组的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.
}https://stackoverflow.com/questions/32100917
复制相似问题