-
Notifications
You must be signed in to change notification settings - Fork 0
/
drimage_improved.api.php
41 lines (37 loc) · 1.09 KB
/
drimage_improved.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* @file
* Hooks and documentation related to drimage_improved module.
*/
use Drupal\image\Entity\ImageStyle;
/**
* Alter the possible proxy cache periods.
*
* @param array $periods
* The array of proxy cache periods.
*/
function hook_drimage_improved_proxy_cache_periods_alter(array &$periods) {
// Set a new proxy cache period.
$periods[] = 32400;
}
/**
* Alter auto-generated image style.
*
* @param \Drupal\image\Entity\ImageStyle $style
* Image style to be created.
*/
function hook_drimage_improved_image_style_alter(ImageStyle &$style) {
// This example adds the `Manual crop` image style effect using a crop type
// with machine name `custom`. This example does not include checking that
// the Crop API module, crop type, or other dependencies exist.
$configuration = [
'id' => 'crop_crop',
'data' => [
'crop_type' => 'custom',
],
'uuid' => NULL,
'weight' => -50,
];
$effect = \Drupal::service('plugin.manager.image.effect')->createInstance($configuration['id'], $configuration);
$style->addImageEffect($effect->getConfiguration());
}