You are here

这样使用image_style_url不生成缩略图了,有点奇怪!

moumouguoguo 的头像
Submitted by moumouguoguo on 星期三, 2014-01-15 08:05

老葛,你好!

$img = image_style_url('small',$value);
$small_pic = replace_image($img);

function replace_image($img){
$match = 'http://www.xxxxxxxx.com/sites/default/files';
$replace = 'http://img.xxxxxxxx.com';
$img= str_replace($match,$replace,$img);
return $img;
}

代码如上,这样使用居然不生成缩略图了,百思不得其解?

我不用替换
function replace_image($img){
return $img;
}

这样完全没问题。但是我想要替换掉原来的才行,请问这是怎么回事,要咋解决呢?

论坛:

Drupal版本:

moumouguoguo 的头像

确实是个好思路。
我照您这样写了
if(!empty($uri)){
$img = image_style_url('small_picture',$uri);
$arr_img = parse_url ($img);
$img_path = $arr_img['path'];
if(file_exists($img_path)){
$img = replace_imgae_cdn($img);
}
}
还是没有效果,不知道哪里的逻辑搞错了,请指点,谢谢!