0

我在用

<?php echo theme('image', array('path' => drupal_get_path('theme', 'themename') .'/img/demo.png')); ?>

将图像硬编码到我的 Drupal 7 主题中。我的问题是如何添加“id”、“class”或“alt”等属性?

4

1 回答 1

1

attributes要添加额外的属性,请传递一个带有必要key => value对的数组。alt与属性相同。

例如:

print theme('image', array(
    'path' => drupal_get_path('theme', 'themename') . '/img/demo.png',
    'alt' => 'my alt content',
    'attributes' => array(
        'id' => 'myId',
        'class' => 'myClass',
    ))
);
于 2013-10-25T23:33:53.790 回答