PHP code example of pubvana / media

1. Go to this page and download the library: Download pubvana/media 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/ */

    

pubvana / media example snippets


'plugins' => [
    'pubvana/media' => [
        'enabled'  => true,
        'priority' => 60,
    ],
],

$media = Flight::media();

// Upload an image
$record = $media->uploadImage($_FILES['photo'], user_id());

// Upload a video
$record = $media->uploadVideo($_FILES['clip'], user_id());

// Store an embed
$record = $media->storeEmbed('https://youtube.com/watch?v=...', user_id());

// List with pagination
$result = $media->list(page: 1, perPage: 24, type: 'image');
// $result = ['items' => [...], 'total' => 42, 'page' => 1, 'per_page' => 24]

// Find / update / delete
$record = $media->find(5);
$media->updateMeta(5, ['alt_text' => 'Sunset photo']);
$media->delete(5); // removes DB record + all files

<?= Flight::media()->picker('avatar', $profile->avatar ?? '')