Image tag

From PHP on Trax

Jump to: navigation, search

image_tag( string $source, array $options = array() )

Description

$source a string which is the image's "src".

The "src" can be supplied as a...

  • full path, like "/my_images/image.gif"
  • file name, like "rss.gif", that gets expanded to "/images/rss.gif"
  • file name without extension, like "logo", that gets expanded to "/images/logo.png"


$options is an array of key => value pairs of options for the image tag.

Returns an image tag converting the $options into html options on the tag, but with these special cases:

  • "alt" - If no alt text is given, the file name part of the "src" is used (capitalized and without the extension)
  • "size" - Supplied as "XxY", so "30x45" becomes width="30" and height="45"

Examples



<?= image_tag("myimage.gif", array("style" => "display:inline")) ?>

<?= image_tag("http://www.domain.com/images/myimage.gif", array("style" => "display:inline")) ?>

<?= image_tag("myimage", array("size" => "20x150")) ?>
Personal tools