Drupal Theming - How to print the attached image?

Ajay on January 29th, 2008

If you are modifying Drupal theme and wish to play with attached image then following code might be helpful.

This code prints attached image (to a node) .

<?php
foreach ($node->files as $file)
{
$fileType = $file->filemime;
if($fileType == ‘image/jpeg’)
{
$imagePath = $file->filepath;
$imageTitle = $file->description;
print ‘<img class=”contentImage” width=”100″ height=”80″ src=”/’.$imagePath.’” alt=”‘.$imageTitle.’” title=”" />’;
}
}
?>

You can modify it as per your requirements. The above code prints all the attached images.

Bookmark and Remember: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • Furl
  • Sphinn
  • Facebook
  • Mixx
  • Google
  • Live
  • YahooMyWeb
  • Technorati
  • blinkbits
  • TwitThis
  • BlinkList
  • StumbleUpon
  • Spurl
  • PlugIM
  • blogmarks
  • Blue Dot
  • TailRank
  • Fark
  • Blogsvine
  • Netvouz
  • NewsVine
  • ppnow
  • Ma.gnolia
  • Taggly
  • MisterWong
  • Simpy
  • Propeller
  • Slashdot
  • Pownce
  • Bumpzee
  • co.mments
  • Blogosphere News

Add a Comment

You must be logged in to post a comment.