hook_image_default_styles()
is entirely removed.
Modules wanting to include default styles can simply include an image.style.[name].json
config file, or use hook_install()
to add their initial image style config.
Modules can specify their style as being a module-provided style by including a "storage" and "module" key in their config file.
Example:
Defining image styles in Drupal 7:
In the .module file of the module:
<?php
function image_image_default_styles() {
$styles = array();
...
$styles['large'] = array(
'label' => 'Large (480x480)',
'effects' => array(
array(
'name' => 'image_scale',
'data' => array(
'width' => 480,
'height' => 480,
'upscale' => 0,
),
'weight' => 0,
),
),
);
return $styles;
}
?>
Defining image styles in image.style.large.json in Backdrop:
Add a JSON file to the config
directory within the module. This configuration file will be copied to the active configuration directory when the module is enabled.
{
"_config_name": "image.style.large.json",
"storage": 4,
"module": "image",
"label": "Large (480x480)",
"name": "large",
"effects": [
{
"name": "image_scale",
"data": {
"width": "480",
"height": "480",
"upscale": 1
},
"weight": 1
}
]
}
Note the "storage" property is optional. If specified as 4 (the IMAGE_STORAGE_DEFAULT
constant in image.module) then the image style will not be allowed to be deleted in the UI. Instead, the style will only allow reverting back to the default. The "module" property is required if "storage" is used.