1. Go to this page and download the library: Download jdz/mediamanager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jdz / mediamanager example snippets
use JDZ\MediaManager\Manager\MediaManager;
use JDZ\MediaManager\ValueObject\MediaConfig;
$manager = new MediaManager(MediaConfig::fromArray([
'rootPath' => $publicPath . 'media/',
'systemFolders' => ['pages', 'documents'], // structural, cannot be moved/renamed/deleted
'extsImage' => ['png', 'gif', 'jpg', 'jpeg'],
'extsDocument' => ['pdf'],
'mimesImage' => ['image/png', 'image/gif', 'image/jpeg'],
'mimesDocument' => ['application/pdf'],
'maxWeightImage' => 2, // Mo, per file
'maxWeightDocument' => 10, // Mo, per file
'maxWeightFiles' => 3000, // Mo, whole library (0 = no quota)
'maxNumFiles' => 6000, // whole library (0 = no quota)
'maxPictureLongSide' => 1200, // px, images above are downscaled on upload
'protectPath' => $publicPath . 'protect/',
'watermarkPath' => $publicPath . 'media/nepascopier.png',
]));
$manager->protectImage('photos', 'img.jpg'); // backs the original up, stamps the watermark over it
$manager->unprotectImage('photos', 'img.jpg'); // restores it, drops the backup
$manager->isProtected('img.jpg');
use JDZ\MediaManager\Tree\ImageTree;
use JDZ\MediaManager\Tree\DocumentTree;
$images = (new ImageTree())
->setBasePath($publicPath . 'media/')
->setBaseUrl('../media/')
->setIgnoreFolders(['template'])
->setIgnoreFiles(['share.jpg'])
->getTree();
// ['folders' => [['label','path','files' => [...]], ...], 'files' => [['url','id','title','ext'], ...]]
$documents = (new DocumentTree())
->setBasePath($publicPath . 'media/')
->setBaseUrl('../media/')
->getTree();
// [['id','title','text','icon','url','ext'], ...]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.