Media Selector¶
- class Nos\Renderer_Media¶
- This renderer is used to pick a file from the media centre.It’s based on the jQuery UI input-file-thumb widget.
Default UI: | |
---|---|
Hover state UI: | |
Hover state with a selected media UI: | |
Configuration¶
- property Nos\Renderer_Media::$mode¶
Possible values are image (default) or all.
- property Nos\Renderer_Media::$inputFileThumb¶
Options for the inputFileThumb widget used to render the UI. See the inputFileThumb documentation for all available options.
Note
The inputFileThumb.file key will automatically be populated with the URL of the media if a value is provided in the renderer.
Methods¶
- Nos\Renderer_Media::renderer($renderer)¶
Parameters: - $renderer (Model) – HTML attributes (name, class, id, value, etc.), with a special key renderer_options
Returns: The <input> tag with JavaScript to initialise it
Displays a media selector in a standalone manner.
Example¶
Adding a media in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Media',
'renderer_options' => array(
'mode' => 'image',
'inputFileThumb' => array(
'title' => 'Title of the image',
),
),
);
Displaying a media selector:
<?php
echo Nos\Renderer_Media::renderer(array(
'name' => 'my_image',
'class' => 'some_class',
'value' => 2, // ID of the previously selected media
'renderer_options' => array(
'mode' => 'image',
'inputFileThumb' => array(
'title' => 'Title of the image',
),
),
));