Actions

API15

JHTMLList/images

From Joomla! Documentation

< API15:JHTMLList
Revision as of 16:21, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
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

[Edit Descripton]

Description:JHTMLList/images

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;
}

[Edit See Also] SeeAlso:JHTMLList/images

Examples

<CodeExamplesForm />