Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在用
<?php echo theme('image', array('path' => drupal_get_path('theme', 'themename') .'/img/demo.png')); ?>
将图像硬编码到我的 Drupal 7 主题中。我的问题是如何添加“id”、“class”或“alt”等属性?
attributes要添加额外的属性,请传递一个带有必要key => value对的数组。alt与属性相同。
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', )) );