Skip to content

diesdasdigital/kirby-3-imgix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kirby 3 imgix plugin Version

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