本文整理汇总了PHP中ElggFile::size方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggFile::size方法的具体用法?PHP ElggFile::size怎么用?PHP ElggFile::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggFile
的用法示例。
在下文中一共展示了ElggFile::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strtolower
$size = strtolower(get_input('size'));
if (!in_array($size, array('master', 'large', 'medium', 'small', 'tiny', 'topbar'))) {
$size = 'medium';
}
// If user doesn't exist, return default icon
if (!$user) {
$path = elgg_view("icon/user/default/{$size}");
header("Location: {$path}");
exit;
}
// Try and get the icon
$filehandler = new ElggFile();
$filehandler->owner_guid = $user->getGUID();
$filehandler->setFilename("profile/" . $user->getGUID() . $size . ".jpg");
$success = false;
if ($filehandler->open("read")) {
if ($contents = $filehandler->read($filehandler->size())) {
$success = true;
}
}
if (!$success) {
$path = elgg_view('icon/user/default/' . $size);
header("Location: {$path}");
exit;
}
header("Content-type: image/jpeg");
header('Expires: ' . date('r', time() + 864000));
header("Pragma: public");
header("Cache-Control: public");
header("Content-Length: " . strlen($contents));
echo $contents;
示例2: elgg_file_viewer_projekktor_video
/**
* Serve a converted web compatible video
* URL structure: projekktor/<guid>/<format>/
*
* @param array $page Page segments array
*/
function elgg_file_viewer_projekktor_video($page)
{
$enable_ffmpeg = elgg_get_plugin_setting('enable_ffmpeg', 'elgg_file_viewer');
if ($enable_ffmpeg != 'yes') {
return false;
}
$guid = elgg_extract(0, $page, null);
$file = get_entity($guid);
if (!elgg_instanceof($file, 'object', 'file')) {
return false;
}
$info = pathinfo($file->getFilenameOnFilestore());
$filename = $info['filename'];
$format = elgg_extract(1, $page);
$output = new ElggFile();
$output->owner_guid = $file->owner_guid;
$output->setFilename("projekktor/{$file->guid}/{$filename}.{$format}");
if (!$output->size()) {
try {
$filestorename = $output->getFilenameOnFilestore();
$output->open('write');
$output->close();
$ffmpeg_path = elgg_get_plugin_setting('ffmpeg_path', 'elgg_file_viewer');
$FFmpeg = new FFmpeg($ffmpeg_path);
$FFmpeg->input($file->getFilenameOnFilestore())->output($filestorename)->ready();
elgg_log("Converting file {$file->guid} to {$format}: {$FFmpeg->command}", 'NOTICE');
} catch (Exception $e) {
elgg_log($e->getMessage(), 'ERROR');
}
}
$mime = elgg_file_viewer_get_mime_type($file);
$base_type = substr($mime, 0, strpos($mime, '/'));
header("Pragma: public");
header("Content-type: {$base_type}/{$format}");
header("Content-Disposition: attachment; filename=\"{$filename}.{$format}\"");
ob_clean();
flush();
readfile($output->getFilenameOnFilestore());
}