PHPackages                             lychee-org/php-flickr-justified-layout - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lychee-org/php-flickr-justified-layout

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

lychee-org/php-flickr-justified-layout
======================================

Port of the famous flikr justified layout JS gallery to php for serverside computation

v1.1.0(2y ago)43.9k[1 issues](https://github.com/LycheeOrg/php-flickr-justified-layout/issues)MITPHP

Since May 14Pushed 2y ago5 watchersCompare

[ Source](https://github.com/LycheeOrg/php-flickr-justified-layout)[ Packagist](https://packagist.org/packages/lychee-org/php-flickr-justified-layout)[ RSS](/packages/lychee-org-php-flickr-justified-layout/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Flickr's Justified Layout in PHP
================================

[](#flickrs-justified-layout-in-php)

[![Build Status](https://camo.githubusercontent.com/b586a0f44c837947415613e2897eb099801d14be7f8cf48aa61d6866ab24cf19/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4c79636865654f72672f7068702d666c69636b722d6a75737469666965642d6c61796f75742f7068702e796d6c)](https://github.com/LycheeOrg/php-flickr-justified-layout/actions)[![Coverage Status](https://camo.githubusercontent.com/c510348acdbb5477a7e66c4e26434d8b841d48dcea6234ab951aa1209df6f842/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f4c79636865654f72672f7068702d666c69636b722d6a75737469666965642d6c61796f7574)](https://app.codecov.io/gh/LycheeOrg/php-flickr-justified-layout)

Pass in box sizes and get back sizes and coordinates for a nice justified layout like that seen all over Flickr. The [explore page](https://www.flickr.com/explore) is a great example. Here's another example using the `fullWidthBreakoutRowCadence` option on Flickr's [album page](https://www.flickr.com/photos/dataichi/albums/72157650151574962).

It converts this (simplified):

```
[0.5, 1.5, 1, 1.8, 0.4, 0.7, 0.9, 1.1, 1.7, 2, 2.1]
```

Into this (simplified):

```
{
    "containerHeight": 1269,
    "widowCount": 0,
    "boxes": [
        {
            "aspectRatio": 0.5,
            "top": 10,
            "width": 170,
            "height": 340,
            "left": 10
        },
        {
            "aspectRatio": 1.5,
            "top": 10,
            "width": 510,
            "height": 340,
            "left": 190
        },
        ...
    ]
}
```

Which gives you everything you need to make something like this:

[![Demonstration](https://cloud.githubusercontent.com/assets/43693/14033849/f5cffb58-f1da-11e5-9763-dce7e90835e1.png)](https://cloud.githubusercontent.com/assets/43693/14033849/f5cffb58-f1da-11e5-9763-dce7e90835e1.png)

Why?
----

[](#why)

Instead of relying on another JS dependency to apply those computations on the client side, this allows us to do them on server side (assuming we know the intended width of the container).

It does come with the constraint that reformating the window may have uninteded effect.

Install
-------

[](#install)

`composer require lychee-org/php-flickr-justified-layout`

Easy Usage
----------

[](#easy-usage)

```
use LycheeOrg\PhpFlickrJustifiedLayout\Contracts\AspectRatio;
use LycheeOrg\PhpFlickrJustifiedLayout\Contracts\WidthHeight;
use LycheeOrg\PhpFlickrJustifiedLayout\LayoutConfig;
use LycheeOrg\PhpFlickrJustifiedLayout\LayoutJustify;

/** @var Collection|Collection $in */
$in;
$layoutJustify = new LayoutJustify();
$config = new LayoutConfig();

$geometry = $layoutJustify->compute($in, $config);
```

Objects passed to the compute method must implement the `AspectRatio` or `WidthHeight` interface.

Configuration
-------------

[](#configuration)

See Config Object:

```
public function __construct(
    int $containerWidth = 1060,
    int|LeftRightTopBottom $containerPadding = 10,
    int|HorizontalVertical $boxSpacing = 10,
    int $targetRowHeight = 320,
    float $targetRowHeightTolerance = 0.25,
    false|int $maxNumRows = false,
    false|float $forceAspectRatio = false,
    bool $showWidows = true,
    false|int $fullWidthBreakoutRowCadence = false,
    string $widowLayoutStyle = 'left',
){...}
```

ParameterTypeDefaultDescription$containerWidth`int``1060`The width that boxes will be contained within irrelevant of padding.$containerPadding`int|LeftRightTopBottom``10`Provide a single integer to apply padding to all sides or provide a LRTB object to apply individual values to each side.$boxSpacing`int|HorizontalVertical``10`Provide a single integer to apply spacing both horizontally and vertically or provide a HV object to apply individual values to each axis.$targetRowHeight`int``320`It's called a target because row height is the lever we use in order to fit everything in nicely. The algorithm will get as close to the target row height as it can.$targetRowHeightTolerance`float``0.25`How far row heights can stray from `targetRowHeight`. `0` would force rows to be the `targetRowHeight` exactly and would likely make it impossible to justify. The value must be between `0` and `1`.$maxNumRows`false|int``false`Will stop adding rows at this number regardless of how many items still need to be laid out.$forceAspectRatio`false|float``false`Provide an aspect ratio here to return everything in that aspect ratio. Makes the values in your input array irrelevant. The length of the array remains relevant.$showWidows`bool``true`By default we'll return items at the end of a justified layout even if they don't make a full row. If `false` they'll be omitted from the output.$fullWidthBreakoutRowCadence`false|int``false`If you'd like to insert a full width box every `n` rows you can specify it with this parameter. The box on that row will ignore the `targetRowHeight`, make itself as wide as `containerWidth - containerPadding` and be as tall as its aspect ratio defines. It'll only happen if that item has an aspect ratio &gt;= 1. Best to have a look at the examples to see what this does.$widowLayoutStyle`string``justify`Justify for the widows, possible values are `left`, `center` and `justify`Open Source Community Support
-----------------------------

[](#open-source-community-support)

[![PhpStorm](https://camo.githubusercontent.com/6e9402fe6304759907d1ff65a5d873dfc03907df2b150e91e2e232a46416629e/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f50687053746f726d5f69636f6e2e706e67)](https://camo.githubusercontent.com/6e9402fe6304759907d1ff65a5d873dfc03907df2b150e91e2e232a46416629e/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f50687053746f726d5f69636f6e2e706e67)

We would like to thank Jetbrains for supporting us with their [Open Source Development - Community Support](https://www.jetbrains.com/community/opensource/) program.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1090d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a33a8047d03c3dee75b8026b1162dd3be07b104027dc697a3461d9b911c6e526?d=identicon)[ildyria](/maintainers/ildyria)

---

Top Contributors

[![ildyria](https://avatars.githubusercontent.com/u/627094?v=4)](https://github.com/ildyria "ildyria (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lychee-org-php-flickr-justified-layout/health.svg)

```
[![Health](https://phpackages.com/badges/lychee-org-php-flickr-justified-layout/health.svg)](https://phpackages.com/packages/lychee-org-php-flickr-justified-layout)
```

###  Alternatives

[illuminate/support

The Illuminate Support package.

583107.1M34.4k](/packages/illuminate-support)[pragmarx/countries

PHP Countries and Currencies

1.9k3.3M18](/packages/pragmarx-countries)[illuminate/events

The Illuminate Events package.

13454.3M1.7k](/packages/illuminate-events)[illuminate/config

The Illuminate Config package.

10842.7M2.2k](/packages/illuminate-config)[illuminate/pagination

The Illuminate Pagination package.

10532.5M857](/packages/illuminate-pagination)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.5M177](/packages/illuminate-broadcasting)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
