You are here

function _imagick_alter_existing_effect_names in Imagick 7

Helper function to alter existing effect names

3 calls to _imagick_alter_existing_effect_names()
imagick_disable in ./imagick.install
Implements hook_disable()
imagick_enable in ./imagick.install
Implements hook_enable()
imagick_update_7100 in ./imagick.install
Updates image effects to work with 7.x-1.1 version

File

./imagick.install, line 41

Code

function _imagick_alter_existing_effect_names($enable = TRUE) {
  $effects = array(
    'image_crop' => 'imagick_crop',
    'image_resize' => 'imagick_resize',
    'image_rotate' => 'imagick_rotate',
  );
  if (!$enable) {
    $effects = array_flip($effects);
  }

  // Load all broken effects
  $result = db_select('image_effects', NULL, array(
    'fetch' => PDO::FETCH_ASSOC,
  ))
    ->fields('image_effects')
    ->condition('name', array_keys($effects), 'IN')
    ->execute()
    ->fetchAll();

  // Update effect name
  foreach ($result as $effect) {
    db_update('image_effects')
      ->fields(array(
      'name' => $effects[$effect['name']],
    ))
      ->condition('ieid', $effect['ieid'])
      ->condition('isid', $effect['isid'])
      ->execute();
  }
}