<?php
//variable for storing globally used constants
$config = array('config_cdn_url'=>'cdndomain.cdn.com', 'protocol'=>'http://');
function createImageSrc($image_data){
global $config;
$src_domain=$config['config_cdn_url'];
if($config['protocol']!='https://'){
$rand=rand(1,6);
$src_domain='cdn'.$rand.'.superbrightleds.com';
}
if(is_array($image_data)){
foreach($image_data as $k=>$v){
if($k='src'){
$v=$config['protocol'].$config['config_cdn_url'].$v;
}
$arr[]=$k.'='.$v;
}
asort($arr);
$query_string=implode(',', $arr);
}else{
$query_string=$image_data;
$arr = split(',', $image_data);
foreach($arr as $v){
$data=split('=',$v);
if($data[0]=='src'){
$data[1]=$config['protocol'].$config['config_cdn_url'].$data[1];
}
$img_props[]=$data[0].'='.$data[1];
}
asort($img_props);
$query_string=implode(',', $img_props);
}
$Idata = $config['protocol'].$src_domain.'/thumb_creation_script.php?'.$query_string;
return ($Idata);
}
//Example usage
$imageSrc = createImageSrc(
array(
'q' => 90,
'src' => '/images/graphics/sample_image.jpg',
'w' => 100
)
);
$img_src=createImageSrc('src=/images/gallery/sample2.jpg&w=55&h=55&zc=1&trim=1');
?>
<?php echo ''; ?>