本文整理汇总了PHP中Provider::thumb方法的典型用法代码示例。如果您正苦于以下问题:PHP Provider::thumb方法的具体用法?PHP Provider::thumb怎么用?PHP Provider::thumb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Provider
的用法示例。
在下文中一共展示了Provider::thumb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Image
/**
* Provide an image to the user, if he is allowed to
* see it. If $thumb is true, provide the thumb associated
* to the image.
*
* @param string $file
* @param string $thumb
* @return void
* @author Thibaud Rohmer
*/
public static function Image($file, $thumb = false, $large = false, $output = true, $dl = false)
{
if (!Judge::view($file)) {
return;
}
if (function_exists("error_reporting")) {
error_reporting(0);
}
/// Check item
$file_type = File::Type($file);
switch ($file_type) {
case "Image":
$is_video = false;
break;
case "Video":
$is_video = true;
break;
default:
return;
}
//error_log('DEBUG/Provider::image: '.$file.' '.($is_video?'is_video':''));
if (!$large) {
try {
if ($is_video) {
//TODO: fix so when opening the folder the first time no need to do F5 to see
//the freshly created thumbnail
Video::FastEncodeVideo($file);
$basefile = new File($file);
$basepath = File::a2r($file);
$path = Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . ".jpg";
} elseif ($thumb) {
// Img called on a video, return the thumbnail
$path = Provider::thumb($file);
} else {
$path = Provider::small($file);
}
} catch (Exception $e) {
// do nothing
}
}
if (!isset($path) || !file_exists($path)) {
error_log('ERROR/Provider::image path:' . $path . ' does not exist, using ' . $file);
$path = $file;
}
if ($output) {
if ($dl) {
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
} else {
$expires = 60 * 60 * 24 * 14;
$last_modified_time = filemtime($path);
$last_modified_time = 0;
$etag = md5_file($file);
header("Last-Modified: " . 0 . " GMT");
header("Pragma: public");
header("Cache-Control: max-age=360000");
header("Etag: {$etag}");
header("Cache-Control: maxage=" . $expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
}
header('Content-type: image/jpeg');
if (File::Type($path) == "Image") {
readfile($path);
return;
try {
imagejpeg(Provider::autorotate_jpeg($path));
} catch (Exception $e) {
error_log('ERROR/Provider.php: cannot rotate ' . $path . ': ' . $e);
readfile($path);
}
} else {
readfile($path);
}
}
}
示例2: get_img
/**
* Return image(s) $img
*/
public static function get_img($key, $img, $t = 'large')
{
if (is_array($img)) {
$res = array();
foreach ($img as $i) {
$p = get_img($key, $i, $t);
if (isset($p)) {
$res[] = $p;
}
}
return $res;
} else {
$i = File::r2a($img);
if (Judge::view($i)) {
switch ($t) {
case "thumb":
return file_get_contents(Provider::thumb($i));
case "small":
return file_get_contents(Provider::small($i));
case "large":
default:
return file_get_contents($i);
}
}
}
}