PHP code example of clippings / fluid-gallery

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

    

clippings / fluid-gallery example snippets


$gallery = new ItemGroup([
    new Item(100, 200, 'http://example.com/1.jpg'),
    new Item(200, 100, 'http://example.com/2.jpg'),
    new Item(100, 100, 'http://example.com/3.jpg'),
    new Item(300, 200, ['url' => 'http://example.com/video.mov', 'type' => 'video']),
]);

$gallery->setMargin(15);

// extract some of the images into another group
$group = $gallery->extract(function ($group) {

    // The returned items are removed from the parent gallery
    return $group
        // get only images with text urls
        ->filter(function (Item $item) {
            return is_string($item->getContent());
        })
        // set the hight of all the images to 50, preserving the aspect ratios
        ->setHeight(50)
        // Get a slice of the images, arranged horizontally, no wider than 200 pixels
        ->horizontalSlice(200)
        // Scale horizontally arranged images to exactly 200, keeping aspect ratios
        ->scaleToWidth(200);
});

foreach ($group as $item) {
    echo $item->getContent();
}

// Get the remaining items
echo $gallery[0]->getContent()['url'];