You are here

function designkit_imagecache_default_presets in DesignKit 6

Implementation of hook_imagecache_default_presets().

File

./designkit.module, line 67

Code

function designkit_imagecache_default_presets() {
  $presets = array();

  // Generate imagecache presets per image entry in theme info.
  $info = designkit_get_info();
  if (!empty($info['designkit']['image'])) {
    foreach ($info['designkit']['image'] as $name => $image_info) {
      if (isset($image_info['imagecache'])) {
        list($action, $dimensions) = explode(':', $image_info['imagecache']);
        list($width, $height) = explode('x', $dimensions);
        $valid_actions = imagecache_action_definitions();
        if (isset($valid_actions[$action]) && is_numeric($width) && is_numeric($height)) {
          $presets["designkit-image-{$name}"] = array(
            'presetname' => "designkit-image-{$name}",
            'actions' => array(
              0 => array(
                'weight' => '0',
                'module' => 'imagecache',
                'action' => $action,
                'data' => array(
                  // @TODO: decide what to do with this hardcoded param.
                  'fit' => 'inside',
                  'width' => $width,
                  'height' => $height,
                ),
              ),
            ),
          );
        }
      }
    }
  }
  return $presets;
}