Posts Tagged "HTML"

Drupal Best Practices : Use Theme Image Function to embed images

Often times, when you are themeing in Drupal, you may have to embed an image inside a template file. If the image is local, then it is best to use the theme_image theme function to embed it rather than using straight HTML tags. This not only makes your HTML output less error prone, but also automatically embeds height and width attributes to the tag. Embedding height and width attributes reduces the amount of repainting that the browser needs to do while rendering a webpage.

Here is sample code, which embeds a User’s Profile Picture.

<?php echo theme('image', $u->picture, $u->name, $u->name, array('class' => 'content_img')); ?>