本文整理汇总了PHP中Thumbnail::createReflection方法的典型用法代码示例。如果您正苦于以下问题:PHP Thumbnail::createReflection方法的具体用法?PHP Thumbnail::createReflection怎么用?PHP Thumbnail::createReflection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thumbnail
的用法示例。
在下文中一共展示了Thumbnail::createReflection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThumb
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;
}
}