Actions

API16

JHtmlList/images

From Joomla! Documentation

< API16:JHtmlList
Revision as of 17:50, 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

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

[Edit See Also] SeeAlso:JHtmlList/images

Examples

<CodeExamplesForm />