diesdasdigital/kirby-3-imgix

Kirby 3 imgix plugin

Installs: 1 759

Dependents: 0

Suggesters: 0

Security: 0

Stars: 20

Watchers: 4

Forks: 4

Open Issues: 4

Type:kirby-plugin

2.0.0 2020-01-22 16:47 UTC

This package is auto-updated.

Last update: 2024-11-11 22:08:25 UTC


README

If this plugin gets activated, it will serve all images (except for gifs) via imgix.

Installation

composer require diesdasdigital/kirby-3-imgix

Configuration

In any config file or the default site/config/config.php:

return [
  'imgix' => true,
  'imgix.domain' => 'https://project-name.imgix.net/',
  'imgix.defaults' => [
    'auto' => 'compress',
  ],
];

imgix.defaults takes a map of options, which all images will have applied automatically without calling thumb().

Usage

All images will automatically be served via imgix if imgix and imgix.domain are set in the config.

The options provided by imgix can be passed via the thumb() function:

$page->someImage()->image()->thumb([
  'blur' => '10',
  'con' => '40',
])->url();

Since version 1.1.0 support for Kirby’s built-in srcset() method is improved to automatically use imgix’s w and h parameters instead of width and height.

$page->someImage()->toFile()->srcset([300, 800, 1024])

// with additional parameters
$page->someImage()->toFile()->srcset([
  300 => [
    'width' => 300,
    'crop' => 'top,left'
  ],
  500 => [
    'width' => 500
  ]
])

See imgix API reference for all options.

imgIX Source Configuration

If you're new to imgIX, you will have to do a few extra steps:

  • Sign up for an account
  • Set up a new source:
    • Pick a subdomain you want you're assets to be referred to.
    • Choose the setting which fits with your server setup (Webfolder if you use default kirby settings ☺️)
    • Add the webfolder url (for Kirby this will be: project-name.com/)

Inspired by Kirby’s website, which uses a custom cloudinary plugin.

Created by diesdas.digital