PHP code example of netliva / medialib

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

    

netliva / medialib example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Netliva\MediaLibBundle\NetlivaMediaLibBundle(),
            new Netliva\FileTypeBundle\NetlivaFileTypeBundle(),
        );

        // ...
    }

    // ...
}


//...
public function buildForm (FormBuilderInterface $formBuilder, array $options)
{
	//...
	$formBuilder->add('images', MediaLibType::class, [ 'label' => 'Images', 'button_text'=>"select file", 'multiple'=>"true"]);
	//...
}
//...
twig
{% for image in get_nl_mfolder(entity.images).files %}
    <img src="{{ image|nl_file_uri }}" />
{% endfor %}
twig
<img src="{{ get_nl_mfile(entity.image)|nl_file_uri }}" />