Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The task is basically to turn the image_sizes variable which looks like this:
Array
(
[_original] => Array
(
[label] => Original
[operation] => scale
[width] =>
[height] =>
[link] => 1
)
[thumbnail] => Array
(
[label] => Thumbnail
[operation] => scale
[width] => 100
[height] => 100
[link] => 1
)
[preview] => Array
(
[label] => Preview
[operation] => scale
[width] => 640
[height] => 640
[link] => 1
)
)
into an image style, where each one looks like this:
array (
'effects' =>
array (
0 =>
array (
'label' => 'Scale',
'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.',
'effect callback' => 'image_scale_effect',
'dimensions callback' => 'image_scale_dimensions',
'form callback' => 'image_scale_form',
'summary theme' => 'image_scale_summary',
'module' => 'image',
'name' => 'image_scale',
'data' =>
array (
'width' => 100,
'height' => 100,
'upscale' => 1,
),
'weight' => 0,
),
),
'name' => 'thumbnail',
'module' => 'image',
'storage' => 4,
)
Furthermore, we need to take into account that the presets from D6 may match up to existing styles. For example, the D6 thumbnail matches the D7 thumbnail.