function getThumb($text, $size = 70, $reflections = false) { preg_match("/\\<img.+?src=\"(.+?)\".+?\\/>/", $text, $matches); $paths = array(); if (isset($matches[1])) { $image_path = $matches[1]; //joomla 1.5 only $full_url = JURI::base(); //remove any protocol/site info from the image path $parsed_url = parse_url($full_url); $paths[] = $full_url; if (isset($parsed_url['path']) && $parsed_url['path'] != "/") { $paths[] = $parsed_url['path']; } foreach ($paths as $path) { if (strpos($image_path, $path) !== false) { $image_path = substr($image_path, strpos($image_path, $path) + strlen($path)); } } // remove any / that begins the path if (substr($image_path, 0, 1) == '/') { $image_path = substr($image_path, 1); } //if after removing the uri, still has protocol then the image //is remote and we don't support thumbs for external images if (strpos($image_path, 'http://') !== false || strpos($image_path, 'https://') !== false) { return false; } // create a thumb filename $file_div = strrpos($image_path, '.'); $thumb_ext = substr($image_path, $file_div); $thumb_prev = substr($image_path, 0, $file_div); $thumb_path = $thumb_prev . "_thumb" . $thumb_ext; // check to see if this file exists, if so we don't need to create it if (function_exists("gd_info") && !file_exists($thumb_path)) { // file doens't exist, so create it and save it include_once 'thumbnail.inc.php'; $thumb = new Thumbnail($image_path); if ($thumb->error) { if (MICRONEWS) { echo "ROKMININEWS ERROR: " . $thumb->errmsg . ": " . $image_path; } return false; } $thumb->resize($size); if ($reflections) { $thumb->createReflection(30, 30, 60, false); } if (!is_writable(dirname($thumb_path))) { $thumb->destruct(); return false; } $thumb->save($thumb_path); $thumb->destruct(); } return $thumb_path; } else { return false; } }