Functions/img

img() is a helper function used to include an image from within a theme. It returns the URL to an image file located in the images directory of that theme, usually located in themes/YourTheme/images. The resulting path can be used in an <img> tag, or anywhere else an image URL is needed.

Usage

<?php  
    img($file,
    $dir = 'images'); 
?>

Arguments

  • $file (string) (required) (default: none) The filename of the image, including the extension
  • $dir (string) (optional) (default: 'images') The directory within the theme directory in which $file is located. Defaults to the standard directory 'images'.

Return Values

  • (string) The URL to the image to be included.

Example(s)

Include an image in a theme file

    <img src="<?php echo img('logo.png'); ?>" />

This code will include the image logo.png from the directory themes/[YOUR THEME]/images/. Be sure to include the extension (e.g., .png, .jpg, .gif) as a part of the file name.

Source File / Version

  • application/helpers/FileFunctions.php in Omeka 1.0.