Media Selector

class Nos\Media\Renderer_Media
Extends Nos\Renderer.
This renderer is used to pick a file from the media centre.
Default UI:Default UI
Hover state UI:Hover state UI
Hover state with a selected media UI:
 Hover state with a selected media UI

Configuration

property Nos\Media\Renderer_Media::$mode

Possible values are image (default) or all.

property Nos\Media\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\Media\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\Media\Renderer_Media',
    'renderer_options' => array(
        'mode' => 'image',
            'inputFileThumb' => array(
            'title' => 'Title of the image',
        ),
    ),
);

Displaying a media selector:

<?php

echo Nos\Media\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',
        ),
    ),
));