function scald_image_update_6001 in Scald: Media Management made easy 6
Implements hook_update_N(). Converts our imagecache based transcoders to use the presetname instead of the presetid as a key. This is more robust to change such as putting presets in code.
File
- scald_image/
scald_image.install, line 49 - Scald Images Installation
Code
function scald_image_update_6001() {
$ret = array();
if (module_exists('imagecache')) {
// Delete the old presets
$ret[] = update_sql("DELETE FROM {scald_transcoders} WHERE transcoder LIKE 'imagecache-%' AND provider='scald_image'");
// Create new ones
_scald_register_provider('scald_image', scald_image_scald_provider(), TRUE);
// Try to migrate the context transcoder settings
$presets = imagecache_presets();
foreach ($presets as $id => $preset) {
$old = 'imagecache-' . $id;
$new = 'imagecache-' . $preset['presetname'];
if ($new != $old) {
$ret[] = update_sql("UPDATE {scald_context_type_transcoder} SET transcoder='{$new}' WHERE transcoder='{$old}'");
}
}
// Rebuild config
scald_config_rebuild();
}
return $ret;
}