API15: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 edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
administrator($file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt=NULL, $attribs=null, $type=1)
| Parameter Name | Default Value | Description |
|---|---|---|
| $file | The file name, eg foobar.png | |
| $directory | '/images/' | The path to the image |
| $param | NULL | empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder |
| $param_directory | '/images/' | Another path. Only used for the contact us form based on the value of the imagelist parm |
| $alt | NULL | Alt text |
| $attribs | null | An associative array of attributes to add |
| $type | 1 | 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
function administrator( $file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt = NULL, $attribs = null, $type = 1 )
{
global $mainframe;
if (is_array( $attribs )) {
$attribs = JArrayHelper::toString( $attribs );
}
$cur_template = $mainframe->getTemplate();
// strip html
$alt = html_entity_decode( $alt );
if ( $param ) {
$image = $param_directory . $param;
} else if ( $param == -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($directory, 0, 14 )== "/administrator" ) {
$image = substr($directory,15) . $file;
} else {
$image = $directory . $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 ( $type ) {
$image = '<img src="'. $image .'" alt="'. $alt .'" '.$attribs.' />';
}
return $image;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples