2015-12-29, 21:36:43
I wanted to auto get thumbs to my custom field "image". So with a little help from a friend I've devised something that works quite well. Im dropping it here, it may come useful. Also - is there a simpler way to do this?
PHP Code:
<?php
$image = $item->image;
$pieces = explode("/",$image);
$needle = "uploads";
$replacement = "thumbs";
for($i=0;$i<count($pieces);$i++) {
if($pieces[$i] == $needle) {
$pieces[$i] = $replacement;
}
}
$f = array_slice($pieces, -1);
$path = array_slice($pieces, 0, -1);
echo implode($path, "/") . "/thumbnail." . implode($f, "/");
?>