API15: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
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
function images( $name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png" ) { if ( !$directory ) { $directory = '/images/stories/'; } 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='../images/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#i", $file ) ) { $images[] = JHTML::_('select.option', $file ); } } $images = JHTML::_('select.genericlist', $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); return $images; }
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />
