本文整理汇总了PHP中thumbnail函数的典型用法代码示例。如果您正苦于以下问题:PHP thumbnail函数的具体用法?PHP thumbnail怎么用?PHP thumbnail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了thumbnail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* 图片上传
* @param array $file 图片文件数组
* @param int $maxSize 允许最大尺寸
* @param array $allowExtension 允许上传图片的扩展名数组
* @param int $is_thumbnail 是否生成缩略图
* @param array $thumbnail_size 缩略图的尺寸和后缀(该参数和$is_thumbnail同时出现同时消失)
* @return array
*/
function upload(array $file, $maxSize, array $allowExtension, $is_thumbnail = 0, array $thumbnail_size)
{
$year = date("Y");
$month = date("m");
$day = date("d");
$targetPath = $_SERVER['DOCUMENT_ROOT'] . "/uploads/{$year}/{$month}/{$day}";
if (!file_exists($targetPath)) {
mkdir($targetPath, 0755, true);
}
if ($file['files']['size'][0] > $maxSize) {
return array('status' => false, 'msg' => '图片文件过大,请选择另外的图片');
} else {
$fileParts = pathinfo($file['files']['name'][0]);
$tempFile = $file['files']['tmp_name'][0];
if (in_array(strtolower($fileParts['extension']), $allowExtension)) {
$uploadFileName = generateTargetFileName($fileParts['extension']);
$targetFile = rtrim($targetPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $uploadFileName;
move_uploaded_file($tempFile, $targetFile);
if ($is_thumbnail) {
foreach ($thumbnail_size as $v) {
thumbnail($targetFile, $v[0], $v[1], $v[2]);
}
}
return array('status' => true, 'src' => 'http://' . $_SERVER['HTTP_HOST'] . "/uploads/{$year}/{$month}/{$day}/" . $uploadFileName, 'filename' => "/uploads/{$year}/{$month}/{$day}/" . $uploadFileName);
} else {
return array('status' => false, 'msg' => '不支持的图片格式');
}
}
}
示例2: thumb_url
function thumb_url($type = '', $filename = '', $thumb_width = 0, $thumb_height = 0, $is_create = false, $is_crop = true, $crop_mode = 'center', $is_sharpen = false, $um_value = '80/0.5/3', $create_animate_thumb = false)
{
if (empty($type) or empty($filename)) {
$filename = 'noimage.gif';
$thumb = thumbnail('', $filename, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value, $create_animate_thumb);
return site_url($thumb);
}
$thumb = thumbnail($type, $filename, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value, $create_animate_thumb);
return site_url($thumb);
}
示例3: images
function images($params)
{
global $template_file;
$template_file = '';
$data = array();
//
$data['path'] = implode('/', $params);
$files_path = STATIC_FILES_ROOT . $data['path'] . '/';
if (!is_dir($files_path)) {
mkdir($files_path, 0775, true);
}
//
if (isset($_FILES['file']) && isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name'] != '') {
include 'interfaces/image_magic.php';
move_uploaded_file($_FILES['file']['tmp_name'], $files_path . $_FILES['file']['name']);
$new_name = time() . '.jpg';
$image = load_image($files_path . $_FILES['file']['name']);
save_image($image, $files_path . $new_name, 'jpg');
//
$thumbnail = thumbnail($image, 160);
save_image($thumbnail, $files_path . 'thumb_' . $new_name, 'jpg');
//
unlink($files_path . $_FILES['file']['name']);
imagedestroy($image);
imagedestroy($thumbnail);
}
//
$data['files'] = array();
if ($dh = opendir($files_path)) {
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..' || is_dir($files_path . '/' . $file)) {
} else {
if (substr($file, 0, 6) == 'thumb_') {
$filemtime = filemtime($files_path . '/' . $file);
$type = strtolower(substr($file, strrpos($file, '.') + 1));
$file_size = filesize($files_path . '/' . $file);
$data['files'][] = array('type' => $type, 'file_size' => intval($file_size / 10.24) / 100, 'created_at' => $filemtime, 'thumb' => $file, 'name' => substr($file, 6));
}
}
}
closedir($dh);
}
return $data;
}
示例4:
$this->date('c');
?>
" itemprop="datePublished"><?php
$this->date('Y-m-d');
?>
</time> |
<span class="glyphicon glyphicon-comment"></span><a href="<?php
$this->permalink();
?>
#comments"><?php
$this->commentsNum('没有评论', '1 条评论', '%d 条评论');
?>
</a>
</dd>
<dd class="thumbnail"><img src="<?php
@thumbnail($this);
?>
" alt="<?php
$this->title();
?>
"></dd>
<dd class="article_list_txt">
<?php
@summary($this);
?>
</dd>
</dl>
</article>
<?php
}
?>
示例5: url
?>
<li class="media">
<div class="mw-ui-row-nodrop">
<?php
if (!isset($show_fields) or $show_fields == false or in_array('thumbnail', $show_fields)) {
?>
<div class="mw-ui-col" style="width: 80px;">
<div class="mw-ui-col-container">
<a href="<?php
print $item['link'];
?>
" class="pull-left bgimg" style="background-image: url(<?php
print thumbnail($item['image'], $tn[0], $tn[1]);
?>
);"></a>
</div>
</div>
<?php
}
?>
<div class="mw-ui-col">
<div class="mw-ui-col-container">
<div class="media-body extra-wrap">
<?php
if (!isset($show_fields) or $show_fields == false or in_array('title', $show_fields)) {
?>
<a href="<?php
print $item['link'];
示例6: session_start
session_start();
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
ini_set('error_prepend_string', "<p class=text-error>");
ini_set('error_append_string', "</p>");
if (!isset($_SESSION["uid"])) {
die("Oups");
}
include_once dirname(__FILE__) . "/ressources/class.templates.inc";
include_once dirname(__FILE__) . "/ressources/class.users.menus.inc";
include_once dirname(__FILE__) . "/ressources/class.miniadm.inc";
include_once dirname(__FILE__) . "/ressources/class.user.inc";
include_once dirname(__FILE__) . "/ressources/class.squid.youtube.inc";
if (isset($_GET["thumbnail"])) {
thumbnail();
exit;
}
if (!$_SESSION["AsWebStatisticsAdministrator"]) {
die("oups");
}
if (isset($_GET["content"])) {
content();
exit;
}
if (isset($_GET["master-content"])) {
master_content();
exit;
}
if (isset($_GET["categories-list"])) {
categories_list();
示例7: get_picture
for ($i = 0; $i < sizeof($cart_items); $i++) {
?>
<?php
$p = get_picture($cart_items[$i]['rel_id']);
?>
<?php
if ($p != false) {
?>
<span data-index="<?php
print $i;
?>
" class="bgimage mw-order-item-image mw-order-item-image-<?php
print $i;
?>
" style="width: 70px;height:70px;background-image:url(<?php
print thumbnail($p, 120, 120);
?>
);"></span>
<?php
}
?>
<?php
}
?>
</div>
<table class="mw-ui-table mw-ui-table-basic" cellspacing="0" cellpadding="0" width="100%" id="order-information-table">
<thead>
<tr>
<th><?php
_e("Product Name");
?>
示例8: mw
?>
" href="<?php
print mw()->url_manager->link_to_file($item);
?>
" onclick="mw.url.windowHashParam('select-file', '<?php
print mw()->url_manager->link_to_file($item);
?>
'); return false;">
<?php
$ext = strtolower(get_file_extension($item));
?>
<?php
if ($ext == 'jpg' or $ext == 'png' or $ext == 'gif' or $ext == 'jpeg' or $ext == 'bmp') {
?>
<img data-src="<?php
print thumbnail(mw()->url_manager->link_to_file($item), 48, 48);
?>
" class="image-item image-item-not-ready" />
<?php
} else {
?>
<span class="mw-fileico mw-fileico-<?php
print $ext;
?>
"><?php
print $ext;
?>
</span>
<?php
}
?>
示例9: get_view_thumbnail
function get_view_thumbnail($contents, $thumb_width = 0)
{
global $board, $config;
if (!$thumb_width) {
$thumb_width = $board['bo_image_width'];
}
// $contents 중 img 태그 추출
$matches = get_editor_image($contents, true);
if (empty($matches)) {
return $contents;
}
for ($i = 0; $i < count($matches[1]); $i++) {
$img = $matches[1][$i];
preg_match("/src=[\\'\"]?([^>\\'\"]+[^>\\'\"]+)/i", $img, $m);
$src = $m[1];
preg_match("/style=[\"\\']?([^\"\\'>]+)/i", $img, $m);
$style = $m[1];
preg_match("/width:\\s*(\\d+)px/", $style, $m);
$width = $m[1];
preg_match("/height:\\s*(\\d+)px/", $style, $m);
$height = $m[1];
preg_match("/alt=[\"\\']?([^\"\\']*)[\"\\']?/", $img, $m);
$alt = get_text($m[1]);
// 이미지 path 구함
$p = parse_url($src);
if (strpos($p['path'], '/' . G5_DATA_DIR . '/') != 0) {
$data_path = preg_replace('/^\\/.*\\/' . G5_DATA_DIR . '/', '/' . G5_DATA_DIR, $p['path']);
} else {
$data_path = $p['path'];
}
$srcfile = G5_PATH . $data_path;
if (is_file($srcfile)) {
$size = @getimagesize($srcfile);
if (empty($size)) {
continue;
}
// jpg 이면 exif 체크
if ($size[2] == 2 && function_exists('exif_read_data')) {
$degree = 0;
$exif = @exif_read_data($srcfile);
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$degree = 90;
break;
case 3:
$degree = 180;
break;
case 6:
$degree = -90;
break;
}
// 세로사진의 경우 가로, 세로 값 바꿈
if ($degree == 90 || $degree == -90) {
$tmp = $size;
$size[0] = $tmp[1];
$size[1] = $tmp[0];
}
}
}
// 원본 width가 thumb_width보다 작다면
if ($size[0] <= $thumb_width) {
continue;
}
// Animated GIF 체크
$is_animated = false;
if ($size[2] == 1) {
$is_animated = is_animated_gif($srcfile);
}
// 썸네일 높이
$thumb_height = round($thumb_width * $size[1] / $size[0]);
$filename = basename($srcfile);
$filepath = dirname($srcfile);
// 썸네일 생성
if (!$is_animated) {
$thumb_file = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, false);
} else {
$thumb_file = $filename;
}
if (!$thumb_file) {
continue;
}
if ($width) {
$thumb_tag = '<img src="' . G5_URL . str_replace($filename, $thumb_file, $data_path) . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"/>';
} else {
$thumb_tag = '<img src="' . G5_URL . str_replace($filename, $thumb_file, $data_path) . '" alt="' . $alt . '"/>';
}
// $img_tag에 editor 경로가 있으면 원본보기 링크 추가
$img_tag = $matches[0][$i];
if (strpos($img_tag, G5_DATA_DIR . '/' . G5_EDITOR_DIR) && preg_match("/\\.({$config['cf_image_extension']})\$/i", $filename)) {
$imgurl = str_replace(G5_URL, "", $src);
$thumb_tag = '<a href="' . G5_BBS_URL . '/view_image.php?fn=' . urlencode($imgurl) . '" target="_blank" class="view_image">' . $thumb_tag . '</a>';
}
$contents = str_replace($img_tag, $thumb_tag, $contents);
}
}
return $contents;
}
示例10: getThumb
function getThumb($path, $filename, $regen = false)
{
global $thumbnailPrefix;
if (!permForPath($path, 'read')) {
jsonStart();
error('You do not have permission for this action.');
return false;
}
$srcImagePath = $path . '/' . $filename;
if (file_exists($srcImagePath)) {
$file = explode('.', $filename);
if (count($file) === 1) {
// Handle no extension
return false;
}
$extension = strtolower(array_pop($file));
$filenameBase = implode('.', $file);
$thumbPath = $path . '/' . $thumbnailPrefix . $filenameBase . '.' . $extension . '.jpg';
if (!file_exists($thumbPath)) {
thumbnail($path, $filename);
}
if ($regen) {
return;
}
$thumb = file_get_contents($thumbPath);
header("Content-type:image/jpeg");
echo $thumb;
} else {
// FIXME: error condition
}
}
示例11: filter_var
$strCategoria = filter_var($strTags[$xf], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$strCategoria = urldecode($strTags[$xf]);
while (false !== ($file = readdir($handle))) {
$fechaRss = gmdate("D, d M Y H:i:s O", (int) filectime($file));
if (filemtime($file) !== FALSE) {
$fechaRss = gmdate("D, d M Y H:i:s O", (int) filemtime($file));
}
$fecha = gmdate("<b>d-M-Y</b> G:i", (int) filectime($file));
if (filemtime($file) !== FALSE) {
$fecha = gmdate("<b>d-M-Y</b> G:i", (int) filemtime($file));
}
$posVarTag = strrpos($file, "_T_");
if ($file != $w . ".xml" && $file != "cache" && $file != "." && $file != ".." && strtolower(substr($file, strrpos($file, '.') + 1)) == 'xml' && strlen($file) > 6 && strpos($strFilesT, utf8_encode($file) . ";", 0) === false && ($posVarTag === false || ($_SESSION['iduserx'] == $cnfAdm || $_SESSION['iduserx'] == $forumMod))) {
//die($strCategoria);
if (strpos(strtolower(utf8_encode($file)), $strCategoria, 0) !== false) {
$thumbnail = thumbnail($file, $cnfHome, $cnfLogo, $cnfThumbnail);
/*echo "<div class='boxForum2in'>"; */
echo '<a href="' . $cnfHome . $pathForumTotal . $auxBlog . $strLink . utf8_encode(basename($file, ".xml") . PHP_EOL) . $strLinkEnd . '"><div class="boxRelated">
<div class="hexagon75" style="background-image:url(' . $thumbnail . ');">
<div class="hexTop75"></div>
<div class="hexBottom75"></div>
</div>
' . str_replace("-", " ", utf8_encode(basename($file, ".xml") . PHP_EOL)) . '
</div></a>';
/* echo "<a class='aFloatMessage'
href='" . $cnfHome . $pathForumTotal . $auxBlog . $strLink . utf8_encode(basename($file, ".xml") . PHP_EOL) . $strLinkEnd . "'><div class='boxRelated'><h5 class='h5Left'>". str_replace("-", " ", utf8_encode(basename($file, ".xml") . PHP_EOL)) . " </h5> Última respuesta: <time class='entry-date' datetime='" . $fechaRss . "'>" . $fecha . "</time></div></a>";*/
$xtag++;
//echo $xtag.">".intval($cnfRelatedSubject)."<br>";
if ($xtag > intval($cnfRelatedSubject)) {
break 2;
}
示例12: foreach
?>
<div class="well mw-module-images">
<div class=" mw-rotator mw-rotator-template-slider" id="<?php
print $id;
?>
">
<div class=" mw-gallery-holder">
<?php
foreach ($data as $item) {
?>
<div class=" mw-gallery-item mw-gallery-item-<?php
print $item['id'];
?>
">
<img src="<?php
print thumbnail($item['filename'], 700);
?>
" alt=""/>
<?php
if ($item['title'] != '') {
?>
<i class="mw-rotator-description"><i
class="mw-rotator-description-content"><?php
print $item['title'];
?>
</i></i><?php
}
?>
</div>
<?php
}
示例13: get_itemuselist_thumbnail
function get_itemuselist_thumbnail($it_id, $contents, $thumb_width, $thumb_height, $is_create = false, $is_crop = true, $crop_mode = 'center', $is_sharpen = true, $um_value = '80/0.5/3')
{
global $g5, $config;
$img = $filename = $alt = "";
if ($contents) {
$matches = get_editor_image($contents, false);
for ($i = 0; $i < count($matches[1]); $i++) {
// 이미지 path 구함
$p = parse_url($matches[1][$i]);
if (strpos($p['path'], '/' . G5_DATA_DIR . '/') != 0) {
$data_path = preg_replace('/^\\/.*\\/' . G5_DATA_DIR . '/', '/' . G5_DATA_DIR, $p['path']);
} else {
$data_path = $p['path'];
}
$srcfile = G5_PATH . $data_path;
if (preg_match("/\\.({$config['cf_image_extension']})\$/i", $srcfile) && is_file($srcfile)) {
$size = @getimagesize($srcfile);
if (empty($size)) {
continue;
}
$filename = basename($srcfile);
$filepath = dirname($srcfile);
preg_match("/alt=[\"\\']?([^\"\\']*)[\"\\']?/", $matches[0][$i], $malt);
$alt = get_text($malt[1]);
break;
}
}
if ($filename) {
$thumb = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
if ($thumb) {
$src = G5_URL . str_replace($filename, $thumb, $data_path);
$img = '<img src="' . $src . '" width="' . $thumb_width . '" height="' . $thumb_height . '" alt="' . $alt . '">';
}
}
}
if (!$img) {
$img = get_it_image($it_id, $thumb_width, $thumb_height);
}
return $img;
}
示例14: isset
?>
" class="bgimage-fader">
<span class="<?php
print isset($pictures[1]) ? 'multiple-thumbnails' : 'single-thumbnail';
?>
" style="background-image: url(<?php
print thumbnail($item['image'], $tn[0], $tn[1]);
?>
);"></span>
<?php
if (isset($pictures[1])) {
?>
<span style="background-image: url(<?php
print thumbnail($pictures[1]['filename'], $tn[0], $tn[1]);
?>
);"></span>
<?php
}
?>
</a>
<?php
}
?>
<div class="module-products-template-slider-item-container">
<?php
if ($show_fields == false or in_array('title', $show_fields)) {
?>
示例15: form_textarea
echo form_textarea('blog_blog', $locale['blog_0425'], $data['blog_blog'], $snippetSettings);
$extendedSettings = array();
if (!fusion_get_settings("tinymce_enabled")) {
$extendedSettings = array("preview" => TRUE, "html" => TRUE, "autosize" => TRUE, "placeholder" => $locale['blog_0426b'], "form_name" => "inputform");
} else {
$extendedSettings = array("type" => "tinymce", "tinymce" => "advanced");
}
echo form_textarea('blog_extended', $locale['blog_0426'], $data['blog_extended'], $extendedSettings);
echo "<div class='row'>\n";
echo "<div class='col-xs-12 col-sm-12 col-md-7 col-lg-8'>\n";
openside('');
if ($data['blog_image'] != "" && $data['blog_image_t1'] != "") {
echo "<div class='row'>\n";
echo "<div class='col-xs-12 col-sm-6'>\n";
$image_thumb = get_blog_image_path($data['blog_image'], $data['blog_image_t1'], $data['blog_image_t2']);
echo "<label>" . thumbnail($image_thumb, '100px');
echo "<input type='checkbox' name='del_image' value='y' /> " . $locale['delete'] . "</label>\n";
echo "</div>\n";
echo "<div class='col-xs-12 col-sm-6'>\n";
$alignOptions = array('pull-left' => $locale['left'], 'blog-img-center' => $locale['center'], 'pull-right' => $locale['right']);
echo form_select('blog_ialign', $locale['blog_0442'], $data['blog_ialign'], array("options" => $alignOptions, "inline" => FALSE));
echo "</div>\n</div>\n";
echo "<input type='hidden' name='blog_image' value='" . $data['blog_image'] . "' />\n";
echo "<input type='hidden' name='blog_image_t1' value='" . $data['blog_image_t1'] . "' />\n";
echo "<input type='hidden' name='blog_image_t2' value='" . $data['blog_image_t2'] . "' />\n";
} else {
$file_input_options = array('upload_path' => IMAGES_B, 'max_width' => $blog_settings['blog_photo_max_w'], 'max_height' => $blog_settings['blog_photo_max_h'], 'max_byte' => $blog_settings['blog_photo_max_b'], 'thumbnail' => 1, 'thumbnail_w' => $blog_settings['blog_thumb_w'], 'thumbnail_h' => $blog_settings['blog_thumb_h'], 'thumbnail_folder' => 'thumbs', 'delete_original' => 0, 'thumbnail2' => 1, 'thumbnail2_w' => $blog_settings['blog_photo_w'], 'thumbnail2_h' => $blog_settings['blog_photo_h'], 'type' => 'image');
echo form_fileinput("blog_image", $locale['blog_0439'], "", $file_input_options);
echo "<div class='small m-b-10'>" . sprintf($locale['blog_0440'], parsebytesize($blog_settings['blog_photo_max_b'])) . "</div>\n";
$alignOptions = array('pull-left' => $locale['left'], 'news-img-center' => $locale['center'], 'pull-right' => $locale['right']);
echo form_select('blog_ialign', $locale['blog_0442'], $data['blog_ialign'], array("options" => $alignOptions));