PHPackages                             romano83/cakephp3-media - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. romano83/cakephp3-media

AbandonedArchivedCakephp-plugin[Utility &amp; Helpers](/categories/utility)

romano83/cakephp3-media
=======================

Media plugin for CakePHP 3

75023[2 issues](https://github.com/Romano83/CakePHP3-Media/issues)[1 PRs](https://github.com/Romano83/CakePHP3-Media/pulls)JavaScript

Since Dec 17Pushed 7y ago4 watchersCompare

[ Source](https://github.com/Romano83/CakePHP3-Media)[ Packagist](https://packagist.org/packages/romano83/cakephp3-media)[ RSS](/packages/romano83-cakephp3-media/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Media plugin for CakePHP 3
==========================

[](#media-plugin-for-cakephp-3)

[![Build Status](https://camo.githubusercontent.com/b49259ab071f65830b1bb86e5ca523fe6892ed58afd5c5e57d4667bb015e8b61/68747470733a2f2f7472617669732d63692e6f72672f526f6d616e6f38332f43616b65504850332d4d656469612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Romano83/CakePHP3-Media)[![Coverage Status](https://camo.githubusercontent.com/bf5deb231b10e9cac6e4acafaa5ff812d8753beb901c2f6a7106195b6e55e688/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f526f6d616e6f38332f43616b65504850332d4d656469612f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/Romano83/CakePHP3-Media?branch=master)

About
-----

[](#about)

The aim of this plugin is to give you the ability to create and associate any kind of medias in your application. *This plugin is the adapation from [Grafikart's Media Plugin](https://github.com/Grafikart/CakePHP-Media) for CakePHP 3.*

### Overview

[](#overview)

- BelongsTo and hasMany Media association for you model;
- Upload using drag &amp; drop based on [dropzone.js](https://github.com/enyo/dropzone/);
- Image uploader integrated with [tinymce 4.2](https://github.com/tinymce/tinymce) and [CKEditor 4.5](https://github.com/ckeditor/ckeditor-dev)

Installation
------------

[](#installation)

### Requirements

[](#requirements)

- [composer](http://getcomposer.org)
- [CakePHP 3.\*](https://github.com/cakephp/cakephp)

### Steps to install

[](#steps-to-install)

- Run :

```
composer require romano83/cakephp3-media

```

- Import The file `config\schema\medias.sql` in your database

How to use
----------

[](#how-to-use)

In your `config\bootstrap.php` file, add this line

```
Plugin::load('Media', ['bootstrap' => false, 'routes' => true]);
```

### Security purpose

[](#security-purpose)

By default, the plugin is blocked for everyone. To set proper permissions, you can implement *canUploadMedia()* method in your `YourApp\AppController`. For exemple :

```
public function canUploadMedias($model, $id){
	if($model === 'YourApp\Model\Table\UsersTable' && $id == $this->Auth->user('id')){
		return true; // Everyone can upload medias for their own records
	}
	return $this->Auth->user('role') == 'admin'; // Admins have all rights
}
```

### Behavior

[](#behavior)

To use this plugin, you must load the `MediaBehavior` in your tables. Form instance, if you want to manage medias for your posts :

```
