Download the PHP package lychee-org/php-flickr-justified-layout without Composer
On this page you can find all versions of the php package lychee-org/php-flickr-justified-layout. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lychee-org/php-flickr-justified-layout
More information about lychee-org/php-flickr-justified-layout
Files in lychee-org/php-flickr-justified-layout
Package php-flickr-justified-layout
Short Description Port of the famous flikr justified layout JS gallery to php for serverside computation
License MIT
Informations about the package php-flickr-justified-layout
Flickr's Justified Layout in PHP
Pass in box sizes and get back sizes and coordinates for a nice justified layout like that seen all
over Flickr. The explore page is a great example. Here's another example using
the fullWidthBreakoutRowCadence
option on Flickr's album page.
It converts this (simplified):
Into this (simplified):
Which gives you everything you need to make something like this:
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
composer require lychee-org/php-flickr-justified-layout
Easy Usage
Objects passed to the compute method must implement the AspectRatio
or WidthHeight
interface.
Configuration
See Config Object:
Parameter | Type | Default | Description |
---|---|---|---|
$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 >= 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
We would like to thank Jetbrains for supporting us with their Open Source Development - Community Support program.