发表时间:2015-05-27来源:网络
因为drupal6中的imagecache preset 已经整合到drupal7的核心中,接下来的这个解决方案是Vladimir提出的,你需要在你的drupal根目录下面创建一个php文件并将以下代码复制进去,执行这个文件.
[php]
<?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";
?>
<?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";
?>happy drupalling
上一篇:php中实现快排与冒泡排序
下一篇:php设计模式――UML类图
CI框架连接数据库配置操作以及多数据库操作
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
C语言关键字及其解释介绍 C语言32个关键字详解
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
PHP中的(++i)前缀自增 和 (i++)后缀自增
将视频设置为Android手机开机动画的教程
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
常用dos命令及语法
PHP中include和require区别之我见
华为智能光伏官方版(FusionSolar)下载v25.3.101.001 安卓版
130.65MB |商务办公
PETKIT小佩宠物官方软件下载v13.1.1 安卓版
300.76MB |系统工具
分包管家app下载v3.7.3 安卓版
58.74MB |商务办公
tplink物联监控摄像头app下载v5.10.5.1681 安卓版
94.39M |社交娱乐
tplink无线摄像头软件(改名tplink物联)下载v5.11.21.1795 安卓手机客户端
94.93MB |系统工具
多屏互动软件下载v10.1.2471 安卓最新版本
108.16MB |系统工具
朴朴森山官方版下载v1.3.3 安卓版
26.43MB |商务办公
aik钥匙工具app下载v2.7.0 安卓版
82.46M |系统工具
2014-09-05
2022-03-20
2022-03-21
2022-03-24
2014-09-05
2014-09-05
2015-07-05
2014-09-05
2022-03-21
2014-09-05