Introduction

An image upload, select, and cropper field type.

Heads Up: The Image field type is a paid addon! Please checkout our store or ask about our developer partnership for repository access.

Configuration

Below is the full configuration available with defaults values:

"example" => [
    "type"   => "anomaly.field_type.image",
    "config" => [
        "folders"       => null,
        "aspect_ratio"  => null,
        "min_height"    => 400
    ]
]
Configuration
Key Example Description

folders

["images", "slides"]

The slugs, paths, or IDs of allowed file folders. Defaults to all folders.

aspect_ratio

1:1

The locked aspect ration of the crop box.

min_height

500

The minimum height of the cropper area.

Installation

The Image field type is a paid addon and requires purchasing from the addon store OR a paid subscription.

Installing from Store Download

You can install the Templates module by downloading the addon and placing it within your site's addon directory:

/addons/{application_ref}/anomaly/*
Installing with Composer Subscription

You can install the Image field type with Composer as a VCS repository if you have a subscription:

{
     "require": {
        "anomaly/image-field_type": "~1.2.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/anomalylabs/image-field_type"
        }
    ]
}

Usage

This section will show you how to use the field type via API and in the view layer.

Basic Output

The image field type always returns null or an \Anomaly\ImageFieldType\Image\Contract\ImageInterface instance which extends \Anomaly\FilesModule\File\Contract\FileInterface.

Example
$entry->example->getName(); // example.jpg
Twig
{{ entry.example.getName() }} // example.jpg

Presenter Output

When accessing the field value from a decorated entry model the an instance of \Anomaly\ImageFieldType\Image\ImagePresenter which extends \Anomaly\FilesModule\File\FilePresenter will be returned.

Example
$decorated->example->path; // local://folder/file.ext

$decorated->example->make()->url() }} // /app/{application}/example/image.jpg
Twig
{{ decorated.example.path }} // local://folder/file.ext

{{ decorated.example.make.url }} // /app/{application}/example/image.jpg

ImagePresenter::cropped()

The cropped method returns an Image instance with the crop data applied.

Returns: \Anomaly\Streams\Platform\Image\Image
Example
$decorated->example->cropped();

$decorated->example->cropped()->path();

$decorated->example->cropped()->widen(100)->path();
Twig
{{ decorated.example.cropped() }}

{{ decorated.example.cropped().path() }}

{{ decorated.example.cropped().widen(100).path() }}