API16:JHtmlList/images
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Build the select list to choose an image
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
static images($name, $active=NULL, $javascript=NULL, $directory=NULL, $extensions="bmp|gif|jpg|png")
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | ||
| $active | NULL | |
| $javascript | NULL | |
| $directory | NULL | |
| $extensions | gif|jpg|png" |
Defined in
libraries/joomla/html/html/list.php
Importing
jimport( 'joomla.html.html.list' );
Source Body
public static function images($name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png") { if (!$directory) { $directory = '/images/'; } if (!$javascript) { $javascript = "onchange=\"javascript:if (document.forms.adminForm." . $name . ".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms.adminForm." . $name . ".options[selectedIndex].value} else {document.imagelib.src='templates/bluestork/images/admin/blank.png'}\""; } jimport('joomla.filesystem.folder'); $imageFiles = JFolder::files(JPATH_SITE.DS.$directory); $images = array(JHtml::_('select.option', '', '- '. JText::_('SELECT_IMAGE') .' -')); foreach ($imageFiles as $file) { if (preg_match('#('.$extensions.')$#', $file)) { $images[] = JHtml::_('select.option', $file); } } $images = JHtml::_( 'select.genericlist', $images, $name, array( 'list.attr' => 'class="inputbox" size="1" '. $javascript, 'list.select' => $active ) ); return $images; }
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />
