Arrange Images with percentages

0.4.0 2020-02-11 10:33 UTC

This package is auto-updated.

Last update: 2022-04-25 14:03:54 UTC


Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version

Arrange Images with percentages


Install via composer

composer require clippings/fluid-gallery


Conseptually, you pile images (or videos) into a ItemGroup and then line by line extract using custom sizing logic.

$gallery = new ItemGroup([
    new Item(100, 200, ''),
    new Item(200, 100, ''),
    new Item(100, 100, ''),
    new Item(300, 200, ['url' => '', 'type' => 'video']),


// 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
        // Get a slice of the images, arranged horizontally, no wider than 200 pixels
        // Scale horizontally arranged images to exactly 200, keeping aspect ratios

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

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


Copyright (c) 2015, Clippings Ltd. Developed by Ivan Kerin

Under BSD-3-Clause license, read LICENSE file.