duanjue9296 2013-10-25 22:52
浏览 16
已采纳

如何在Drupal 7主题中向硬编码图像添加属性

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"?

  • 写回答

1条回答 默认 最新

  • donglizhan7848 2013-10-25 23:33
    关注

    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',
        ))
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?