Because the Imagecache preset in DRUPAL6 has been integrated into the core of DRUPAL7, the next solution is Vladimir, you need to create a PHP file under your Drupal root directory and copy the following code to execute the file .
[PHP]
Define (' Drupal_root ', GETCWD ());
Require_once
Drupal_root. '/includes/bootstrap.inc ';
Drupal_bootstrap (Drupal_bootstrap_full);
/////////////////////////////////////////////////
function Imagecache_preset_actions ($preset, $reset = FALSE) {
$actions _cache = Array ();
$result = Db_query (' SELECT * from {imagecache_action} where Presetid = '. $preset [' Presetid ']. ' ORDER by weight ');
foreach ($result as $row) {
$row = (array) $row;
$row [' data '] = unserialize ($row [' data ']);
$actions _cache[$preset [' Presetid ']][] = $row;
}
Return Isset (
$actions _cache[$preset [' Presetid ']]? $actions _cache[$preset [' Presetid ']: Array ();
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
function Imagecache_presets () {
$presets = Array ();
$normal _presets = Array ();
$result = Db_query (' SELECT * from {imagecache_preset} ORDER by Presetname ');
foreach ($result as $preset) {
$preset = (array) $preset;
$presets [$preset [' presetid ']] = $preset;
$presets [$preset [' Presetid ']][' actions '] = Imagecache_preset_actions ($preset);
$presets [$preset [' Presetid ']][' storage '] = 0;
Collect Normal preset names so we can skip defaults and mark overrides accordingly
$normal _presets[$preset [' presetname ']] = $preset [' Presetid '];
}
Return
$presets;
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
$styles _cnt=0;
$effects _new_cnt=0;
$effects _ext_cnt=0;
$presets =imagecache_presets ();
foreach ($presets as $preset)
{
$styles _cnt++;//Inc Styles
$style =image_style_load ($preset [' presetname ']);
$style [' name ']= $preset [' Presetname '];
$style =image_style_save ($style);
if (!isset ($style [' effects ')])
{
$style [' Effects ']=array ();
}
foreach ($preset [' actions '] as $action)
{
$action [' Action ']=str_replace (' imagecache ', ' image ', $action [' action ']);
$action [' Module ']=str_replace (' imagecache ', ' image ', $action [' module ']);
$effect _ieid=false;//effect NOT exists
foreach ($style [' effects '] as $effect)
{
if ($effect [' name '] = = $action [' Action '] &&
$effect [' module '] = = $action [' module '] &&
$effect [' weight '] = = $action [' Weight '] &&
$effect [' data '] = = $action [' Data ']
{
$effect _ieid= $effect [' Ieid '];//effect exists
}
}
$effect =array ();
if ($effect _ieid)
{
$effects _ext_cnt++;//Inc exists
$effect =image_effect_load ($effect _ieid, $style [' name ']);
}
Else
{
$effects _new_cnt++;//Inc New
$effect =image_effect_definition_load ($action [' action ']);
}
$effect [' isid '] = $style [' Isid '];
$effect [' name '] = $action [' Action '];
$effect [' module '] = = $action [' module '];
$effect [' weight '] = $action [' Weight '];
$effect [' data '] = $action [' Data '];
$effect = Image_effect_save ($effect);
$style [' Effects '] [$effect [' Ieid ']] = $effect;
}
$style =image_style_save ($style);
}
Print
"Styles: $styles _cnt, effects new: $effects _new_cnt, effects exists: $effects _ext_cnt \ n";
?>
Define (' Drupal_root ', GETCWD ());
Require_once
Drupal_root. '/includes/bootstrap.inc ';
Drupal_bootstrap (Drupal_bootstrap_full);
/////////////////////////////////////////////////
function Imagecache_preset_actions ($preset, $reset = FALSE) {
$actions _cache = Array ();
$result = Db_query (' SELECT * from {imagecache_action} where Presetid = '. $preset [' Presetid ']. ' ORDER by weight ');
foreach ($result as $row) {
$row = (array) $row;
$row [' data '] = unserialize ($row [' data ']);
$actions _cache[$preset [' Presetid ']][] = $row;
}
Return Isset (
$actions _cache[$preset [' Presetid ']]? $actions _cache[$preset [' Presetid ']: Array ();
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
function Imagecache_presets () {
$presets = Array ();
$normal _presets = Array ();
$result = Db_query (' SELECT * from {imagecache_preset} ORDER by Presetname ');
foreach ($result as $preset) {
$preset = (array) $preset;
$presets [$preset [' presetid ']] = $preset;
$presets [$preset [' Presetid ']][' actions '] = Imagecache_preset_actions ($preset);
$presets [$preset [' Presetid ']][' storage '] = 0;
Collect Normal preset names so we can skip defaults and mark overrides accordingly
$normal _presets[$preset [' presetname ']] = $preset [' Presetid '];
}
Return
$presets;
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
$styles _cnt=0;
$effects _new_cnt=0;
$effects _ext_cnt=0;
$presets =imagecache_presets ();
foreach ($presets as $preset)
{
$styles _cnt++;//Inc Styles
$style =image_style_load ($preset [' presetname ']);
$style [' name ']= $preset [' Presetname '];
$style =image_style_save ($style);
if (!isset ($style [' effects ')])
{
$style [' Effects ']=array ();
}
foreach ($preset [' actions '] as $action)
{
$action [' Action ']=str_replace (' imagecache ', ' image ', $action [' action ']);
$action [' Module ']=str_replace (' imagecache ', ' image ', $action [' module ']);
$effect _ieid=false;//effect NOT exists
foreach ($style [' effects '] as $effect)
{
if ($effect [' name '] = = $action [' Action '] &&
$effect [' module '] = = $action [' module '] &&
$effect [' weight '] = = $action [' Weight '] &&
$effect [' data '] = = $action [' Data ']
{
$effect _ieid= $effect [' Ieid '];//effect exists
}
}
$effect =array ();
if ($effect _ieid)
{
$effects _ext_cnt++;//Inc exists
$effect =image_effect_load ($effect _ieid, $style [' name ']);
}
Else
{
$effects _new_cnt++;//Inc New
$effect =image_effect_definition_load ($action [' action ']);
}
$effect [' isid '] = $style [' Isid '];
$effect [' name '] = $action [' Action '];
$effect [' module '] = = $action [' module '];
$effect [' weight '] = $action [' Weight '];
$effect [' data '] = $action [' Data '];
$effect = Image_effect_save ($effect);
$style [' Effects '] [$effect [' Ieid ']] = $effect;
}
$style =image_style_save ($style);
}
Print
"Styles: $styles _cnt, effects new: $effects _new_cnt, effects exists: $effects _ext_cnt \ n";
? >happy drupalling
http://www.bkjia.com/PHPjc/477273.html www.bkjia.com true http://www.bkjia.com/PHPjc/477273.html techarticle because the Imagecache preset in DRUPAL6 has been integrated into the core of DRUPAL7, the next solution is Vladimir, you need to create a ph under your Drupal root directory ...