4

How can select a video file (mp4, ogv, webm ...) in a plugin as parameter?

I intend to select a video file in a plugin parameters, tried field type media but videos files are not listed. Using field type filelist they are listed.

The only way is to use filelist field type?

1
  • media field type lists only images
    – FFrewin
    Commented Aug 13, 2015 at 18:24

3 Answers 3

6

The best way to allow video selection in an extension field is to use a custom field. For an introduction to custom fields, take a look at this article from Joomla! Documentation.

In its simplest form, you can simply extend the filelist field type and make it list video files using the formats you want. Here's an example (based on the imagelist field type):

File: /modules/mod_YOURMODULE/models/fields/videos.php

<?php

defined('JPATH_PLATFORM') or die;

JFormHelper::loadFieldClass('filelist');

class JFormFieldVideos extends JFormFieldFileList
{
    protected $type = 'ImageList';
    protected function getOptions()
    {
        // Define the vide file type filter. Edit as needed.
        $this->filter = '\.mov$|\.mpg$|\.mp4$|\.ogv$|\.webm$|\.mts$|\.avi$|\.wmv$';
        return parent::getOptions();
    }
}

File: /modules/mod_YOURMODULE/mod_YOURMODULE.xml

<fieldset name="videos" addfieldpath="/modules/mod_YOURMODULE/models/fields">
       <field name="videos" type="Videos" label="Select a video" description="" directory="images"  /> 
</fieldset>

It's not as elegant as the media manager popup, but the same method can be used to create a more complex form if you know how.

The same can also be achieved by adding filters to the filelist form field directly:

<field type="filelist" name="test" label="Video filter" directory="images" filter="\.mov$|\.mpg$|\.mp4$|\.ogv$|\.webm$|\.mts$|\.avi$|\.wmv$" />

(A related question with a couple of answers can be found here.)

0

Try to add proper extensions and mime types in com_media settings. If that will not help it is possible you will have to create your own field type for that.

1
  • Adding extensions didn't work but thanks anyway
    – n.h.
    Commented Jul 14, 2015 at 16:20
0

You can use JCE editor with plugin media manager addon.

https://www.joomlacontenteditor.net/downloads/plugins/media-manager

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.