elFinder

1.3 version
Maintained Unmaintained

elFinder

The media browser elFinder is integrated with Symfony using the FMElfinderBundle. The MediaBundle provides an adapter to use it with objects implementing the MediaBundle interfaces.

Note

The MediaBundle elFinder adapter is currently only implemented for Doctrine PHPCR-ODM.

Installation

  1. Install the FMElfinderBundle according to the FMElfinderBundle documentation.

  2. Configure the FMElfinderBundle to use the MediaBundle adapter:

    • YAML
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      # app/config/config.yml
      fm_elfinder:
          instances:
              default:
                  locale: "%locale%"
                  editor: ckeditor
                  connector:
                      roots:
                          media:
                              driver: cmf_media.adapter.elfinder.phpcr_driver
                              path: "%cmf_media.persistence.phpcr.media_basepath%"
                              upload_allow: ['all']
                              upload_max_size: 2M
      
    • XML
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      <!-- app/config/config.xml -->
      <?xml version="1.0" charset="UTF-8" ?>
      <container xmlns="http://symfony.com/schema/dic/services">
      
          <config xmlns="http://example.org/dic/schema/fm_elfinder">
              <instances
                  locale="%locale%"
                  editor="ckeditor"
              >
                  <default>
                      <connector>
                          <root
                              name="media"
                              driver="cmf_media.adapter.elfinder.phpcr_driver"
                              path="%cmf_media.persistence.phpcr.media_basepath%"
                              upload-max-size="2M"
                              upload-allow="all"
                          />
                      </connector>
                  </default>
              </instances>
          </config>
      </container>
      
    • PHP
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
       // app/config/config.php
       $container->loadFromExtension('fm_elfinder', array(
           'instances' => array(
               'default' => array(
                   'locale' => '%locale%',
                   'editor' => 'ckeditor',
                   'connector' => array(
                       'roots' => array(
                           'media' => array(
                               'driver' => 'cmf_media.adapter.elfinder.phpcr_driver',
                               'path' => '%cmf_media.persistence.phpcr.media_basepath%',
                               'upload_allow': array('all'),
                               'upload_max_size' => '2M',
                           ),
                      ),
                   ),
               ),
           ),
      ));
      

New in version 2.0: The above configuration is intended for the FMElfinderBundle version 2.0 and above. Version 1 used a different format without the possibility to configure more than one editor.

Note

The driver service depends on your storage layer. For now, the MediaBundle only provides a PHPCR driver. To make the above configuration work, you need to enable PHPCR either globally on cmf_core.persistence:phpcr or, if you only use the MediaBundle, directly on the bundle at cmf_media.persistence.phpcr.

  1. When using the LiipImagineBundle, add an imagine filter for the thumbnails:

    • YAML
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      # app/config/config.yml
      liip_imagine:
          # ...
          filter_sets:
              # default filter to be used for elfinder thumbnails
              elfinder_thumbnail:
                  data_loader: cmf_media_doctrine_phpcr
                  quality: 85
                  filters:
                      thumbnail: { size: [48, 48], mode: inset }
              # ...
      
    • XML
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      <!-- app/config/config.xml -->
      <?xml version="1.0" charset="UTF-8" ?>
      <container xmlns="http://symfony.com/schema/dic/services">
      
          <config xmlns="http://example.org/dic/schema/liip_imagine">
              <!-- ... -->
              <!-- default filter to be used for elfinder thumbnails -->
              <filter-set name="elfinder_thumbnail" data-loader="cmf_media_doctrine_phpcr" quality="85">
                  <filter name="thumbnail" size="48,48" mode="inset"/>
              </filter-set>
              <!-- ... -->
          </config>
      
      </container>
      
    • PHP
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      // app/config/config.php
      $container->loadFromExtension('liip_imagine', array(
          // ...
          'filter_sets' => array(
              // default filter to be used for elfinder thumbnails
              'elfinder_thumbnail' => array(
                  'data_loader' => 'cmf_media_doctrine_phpcr',
                  'quality'     => 85,
                  'filters'     => array(
                      'thumbnail' => array(
                          'size' => array(48, 48),
                          'mode' => 'inset',
                      ),
                  ),
              ),
              // ...
          ),
      ));
      
  2. Test the elFinder browser by navigating to: http://<yoursite>/app_dev.php/elfinder

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.