You are here

function imagecache_canvasactions_update_6201 in ImageCache Actions 6.2

Changed aspect switcher from presetid to presetname as a key DRUPAL-6--2-0 (pre-release 1)

File

canvasactions/imagecache_canvasactions.install, line 26
Set up new canvas actions. Tell imagecache.module about them

Code

function imagecache_canvasactions_update_6201() {
  $count = 0;
  foreach (imagecache_presets(TRUE) as $preset_id => $preset) {
    foreach ($preset['actions'] as $action_id => $action) {
      if ($action['action'] == 'canvasactions_aspect') {

        // Convert from presetid to presetname
        foreach (array(
          'portrait',
          'landscape',
        ) as $aspect) {
          $old_id = $action['data'][$aspect];
          if (is_numeric($old_id)) {
            $old_preset = imagecache_preset($old_id);

            // Set it!
            if ($old_preset) {
              $action['data'][$aspect] = $old_preset['presetname'];
              imagecache_action_save($action);
              $count++;
            }
            else {
              drupal_set_message("Could not update {$preset_id} fully. You'd better check it.", 'warning');
            }
          }
        }
      }
    }
  }
  drupal_set_message(($count ? $count : "no") . " actions updated");
  return array();
}