unifik/media-bundle

The media bundle of the symfony-unifik distribution

Installs: 577

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 9

Forks: 4

Open Issues: 6

Language:JavaScript

Type:symfony-bundle

0.1.2 2017-05-15 17:44 UTC

This package is not auto-updated.

Last update: 2022-01-22 02:28:44 UTC


README

Installation

Using composer file :

"require": {
    //...,
    "unifik/media-bundle": "dev-master"
},

Add the following line to AppKernel.php :

new Unifik\MediaBundle\UnifikMediaBundle(),

In app/config/routing.yml add the following:

unifik_media_backend:
    resource: "@UnifikMediaBundle/Resources/config/routing_backend.yml"
    prefix:   /admin/media

To activate the media manager with CKEditor once the bundle is loaded, you must register the plugin in the ckeditor config (app/config/config.yml):

external_plugins:
    unifikmediamanager:
        path: bundles/unifikmedia/backend/js/ckeditor/plugin/unifikmediamanager

You must also add the 'Insert_media' button in one toolbar. An example of config:

trsteel_ckeditor:
  toolbar_groups:
      [...]
      insert: ['Insert_media', 'Image', 'Flash', 'Table', 'HorizontalRule']
      [...]

To get the proper media select field in your form, your need to add those lines in your form theme:

{% block media_select_widget %}
    {% include 'UnifikMediaBundle:Backend/Form:fields.html.twig' with {'widget_attributes': block('widget_attributes')} %}
{% endblock %}

This bundle use FOSRoutingBundle. So you need to include the following js files:

{% javascripts
    'bundles/fosjsrouting/js/router.js'
    'js/fos_js_routes.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

And run this command: app/console fos:js-routing:dump

Include the dynamic_loader.js file required to add the Media Bundle CKEditor Plugin:

{% javascripts
    '@UnifikMediaBundle/Resources/public/backend/js/dynamic_loader.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

Include the liip imagine routing in your config.yml file:

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

Bundle requirements

  • unifik/doctrine-behaviors-bundle
  • liip/imagine-bundle
  • friendsofsymfony/jsrouting-bundle

Add Media field

To link media with entity, add the manyToOne relation as follow:

manyToOne:
  myMedia:
    targetEntity: Unifik\MediaBundle\Entity\Media

To generate de media field, add this in your form type: (default type is image)

->add('image2', 'media_select')

To choose an other media type: (available types are: image, video, embedvideo and document)

->add('image2', 'media_select', array('type' => 'image'))