Reputation: 2719
I am using
<?php echo theme('image', array('path' => drupal_get_path('theme', 'themename') .'/img/demo.png')); ?>
To hard code images into my Drupal 7 theme. My question is how do I add attributes like "id", "class" or "alt"?
Upvotes: 0
Views: 490
Reputation: 5577
To add extra attributes, you pass an array attributes
with the necessary key => value
pair. Identical for the alt
attribute.
For example:
print theme('image', array(
'path' => drupal_get_path('theme', 'themename') . '/img/demo.png',
'alt' => 'my alt content',
'attributes' => array(
'id' => 'myId',
'class' => 'myClass',
))
);
Upvotes: 1