API16

API16:JHtmlImage/administrator

From Joomla! Documentation

Description

Checks to see if an image exists in the current templates image directory if it does it loads this image. Otherwise the default image is loaded. Also can be used in conjunction with the menulist param to create the chosen image load the default or use no image


<! removed transcluded page call, red link never existed >

Syntax

static administrator($file, $folder= '/images/', $altFile=null, $altFolder= '/images/', $alt=null, $attribs=null, $asTag=true)
Parameter Name Default Value Description
$file $file The file name, eg foobar.png.
$folder '/images/' $folder The path to the image.
$altFile null $altFile Empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder.
$altFolder '/images/' $altFolder Another path. Only used for the contact us form based on the value of the imagelist param.
$alt null $alt Alternative text.
$attribs null $attribs An associative array of attributes to add.
$asTag true $asTag True (default) to display full tag, false to return just the path.

Defined in

libraries/joomla/html/html/image.php

Importing

jimport( 'joomla.html.html.image' );

Source Body

public static function administrator($file, $folder = '/images/', $altFile = null, $altFolder = '/images/', $alt = null, $attribs = null, $asTag = true)
{
        $app = &JFactory::getApplication();

        if (is_array($attribs)) {
                $attribs = JArrayHelper::toString($attribs);
        }

        $cur_template = $app->getTemplate();

        // Strip HTML.
        $alt = html_entity_decode($alt, ENT_COMPAT, 'UTF-8');

        if ($altFile) {
                $image = $altFolder . $altFile;
        }
        else if ($altFile == -1) {
                $image = '';
        }
        else
        {
                if (file_exists(JPATH_ADMINISTRATOR .'/templates/'. $cur_template .'/images/'. $file)) {
                        $image = 'templates/'. $cur_template .'/images/'. $file;
                }
                else
                {
                        // Compability with previous versions.
                        if (substr($folder, 0, 14) == "/administrator") {
                                $image = substr($folder, 15) . $file;
                        } else {
                                $image = $folder . $file;
                        }
                }
        }

        if (substr($image, 0, 1) == "/") {
                $image = substr_replace($image, '', 0, 1);
        }

        // Prepend the base path.
        $image = JURI::base(true).'/'.$image;

        // Outputs actual html <img> tag.
        if ($asTag) {
                $image = '<img src="'. $image .'" alt="'. $alt .'" '.$attribs.' />';
        }

        return $image;
}


<! removed transcluded page call, red link never existed >

Examples

Code Examples