Skip to content

Instantly share code, notes, and snippets.

@projoomexperts
Created June 27, 2015 07:34
Show Gist options
  • Save projoomexperts/35b1b1613fc322470373 to your computer and use it in GitHub Desktop.
Save projoomexperts/35b1b1613fc322470373 to your computer and use it in GitHub Desktop.
function img_process( $src , $size ) {
$pathinfo = pathinfo($src);
$pathname = $pathinfo['dirname'];
$filename = $pathinfo['basename'];
if($src){
if($size == 'xs'){
echo $pathname.'/4_'.$filename;
} elseif ($size == 'sm') {
echo $pathname.'/3_'.$filename;
} elseif ($size == 'md') {
echo $pathname.'/2_'.$filename;
} else {
echo $pathname.'/'.$filename;
}
} else {
if($size == 'xs'){
echo 'http://placehold.it/142x87';
} elseif ($size == 'sm') {
echo 'http://placehold.it/220x135';
} elseif ($size == 'md') {
echo 'http://placehold.it/204x156';
} else {
echo 'http://placehold.it/370x216';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment