mandarinmedien / mmmmediabundle
YAMB -> Yet another Media bundle
Installs: 186
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 1
Type:symfony-bundle
Requires
- knplabs/gaufrette: ^0.2
- symfony/symfony: ^2.8|^3.0
- 3.0.0
- 2.2.15
- 2.2.14
- 2.2.13
- 2.2.12
- 2.2.11
- 2.2.10
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.12
- 2.1.11
- 2.1.10
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0
- 1.0
- 0.1.5.3
- 0.1.5.1
- 0.1.5
- 0.1.4.1
- 0.1.4
- 0.1.3
- 0.1.2.1
- 0.1.2
- 0.1.1
- 0.1.0
- dev-MM-Psiiirus-symfony-4
- dev-feature/symfony-3-support
This package is auto-updated.
Last update: 2024-10-25 10:42:16 UTC
README
Append to app/AppKernel.php
...
public function registerBundles()
{
$bundles = array(
...
new MandarinMedien\MMMediaBundle\MMMediaBundle(),
...
);
....
}
...
Append to app/config/config.yml
...
imports:
- { resource: '@MMMediaBundle/Resources/config/config.yml' }
...
Append to App/config/routing.yml
...
mm_media:
resource: "@MMMediaBundle/Resources/config/routing.yml"
prefix: /mmmedia
...
Create web/media folder to store images
...
shell: mkdir PROJECT_ROOT/web/media
...
Use MMMediaBundle in your Entities
You need to use the MediaSortable Entity of this bundle to have sortable Media. For a collection of media, use an unidirectional manyToMany-association and for single media an unidirectional oneToOne. To avoid garbage in your database, make sure to set the orphanRemoval flag.
eg. yaml configuration for single media:
...
oneToOne:
titleImage:
targetEntity: MandarinMedien\MMMediaBundle\Entity\MediaSortable
cascade:
- persist
- remove
...
eg. yaml configuration for media collection:
...
manyToMany:
medias:
targetEntity: MandarinMedien\MMMediaBundle\Entity\MediaSortable
orderBy: { 'position': 'ASC' }
joinColumn:
name: media_sortable_id
referencedColumnName: id
cascade:
- persist
- remove
orphanRemoval: true
...
Add all needed Assets to your layout
To make the MMMediaBundle-UploadWidget work properly you need to add the necessary CSS and the JS files. Your can just copy this part below or add @mmmedia_assets_css and @mmmedia_assets_js into your asset calls.
Twig-Example:
...
{% stylesheets '@mmmedia_assets_css' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% javascripts '@mmmedia_assets_js' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
...
FormType Options
...
$builder
->add('medias', 'mmmedia_upload_collection', array(
// optional: configure allowed filetypes by file-extensions
'allowed_filetypes' => array(
'.jpg', '.png', '.gif'
)
));
...