vitamin2 / v2-image-factory
V2 Image Factory
0.2.1
2022-11-15 08:16 UTC
Requires
This package is auto-updated.
Last update: 2024-04-15 11:42:40 UTC
README
Just an image factory
Installation
Download
Download and copy this repository to /site/plugins/v2-image-factory
.
Composer
composer require vitamin2/v2-image-factory
Setup
Install plugin
Add Image Factory JS to your template (getFactoryJS returns a versionised JS file)
<?= js([
getFactoryJs(),
]) ?>
- Preload it (optional)
<link rel="preload" href="<?= getFactoryJs() ?>" as="script" />
Usage
imageURL choose image
imageType choose crop type
- variousHeights (choose this if you have differnt image heights, e.g for base image or logos)
- cropToRatio (choose this if you have a fixed ratio e.g. for gallery, headers)
- cropToRatioMultiple (choose this if you have 2 ratios, mobile and desktop)
imageRatio (for cropToRatio and cropToRatioMultiple) choose image ratio (e.g. 16/9 = 1.777 or 4/3 = 1.333)
imageRatioDesktop (for cropToRatioMultiple) choose image ratio for Desktop
imageCustomClass add a custom class here
imageCropToPoint (for cropToRatio, cropToRatioMultiple) select crop point
- default is center, but you can also set left, top, etc.
snippet('global/image-factory', [
'imageURL' => $data->gallery()->toFile(),
'imageType' => 'variousHeights',
'imageRatio' => '1.333',
'imageRatioDesktop' => '3',
'imageCustomClass' => '',
'imageCropToPoint' => 'center'
])
License
MIT