本文整理汇总了PHP中generate_thumb函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_thumb函数的具体用法?PHP generate_thumb怎么用?PHP generate_thumb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_thumb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plogger_get_album_thumb
function plogger_get_album_thumb()
{
$rv = $GLOBALS["current_album"];
// figure out the thumbnail as well
$thumb_query = "SELECT * FROM `" . TABLE_PREFIX . "pictures` WHERE ";
if ($rv["thumbnail_id"] > 0) {
$thumb_query .= " `id`=" . $rv["thumbnail_id"];
} else {
$thumb_query .= " `parent_album`='" . $rv["id"] . "' ORDER BY `date_submitted` DESC LIMIT 1";
}
$thumb_result = run_query($thumb_query);
$thumb_data = mysql_fetch_assoc($thumb_result);
if ($thumb_data) {
$rv["thumbnail_id"] = $thumb_data["id"];
$rv["thumbnail_path"] = $thumb_data["path"];
}
return generate_thumb($rv['thumbnail_path'], $rv['thumbnail_id'], THUMB_SMALL);
}
示例2: get_files
<?php
// this will create a picture thumbnail on disk
// first it will be used for import only.
if (empty($_GET["img"])) {
return "No such image";
}
require_once "../plog-functions.php";
require_once "../plog-globals.php";
require_once "../plog-load_config.php";
require_once "plog-admin-functions.php";
$files = get_files($config['basedir'] . 'uploads');
$found = false;
$up_dir = $config['basedir'] . 'uploads';
foreach ($files as $file) {
if (md5($file) == $_GET["img"]) {
$found = true;
$rname = substr($file, strlen($up_dir) + 1);
$thumbpath = generate_thumb($up_dir . '/' . $rname, "import", THUMB_SMALL);
print '<img src="' . $thumbpath . '" /></div>';
//print "found $relative_name!";
break;
}
}
示例3: get_picture_by_id
<?php
require_once "plog-admin.php";
require_once "../plog-load_config.php";
// load configuration variables from database
require_once "../plog-functions.php";
// this script will just show a small preview of the thumbnail in admin view if
// you can't differentiate the small pics.
echo '<html><head>
<body>';
$src = $_REQUEST['src'];
$picture = get_picture_by_id($src);
$id = $picture["id"];
$thumbpath = generate_thumb($picture["path"], $picture["id"], THUMB_LARGE);
$thumbdir = $config["basedir"] . "thumbs/lrg-{$id}-" . basename($picture["path"]);
list($width, $height, $type, $attr) = getimagesize($thumbdir);
// print $thumbdir;
echo '
<script language="JavaScript">
<!--
this.resizeTo(' . $width . '+25,' . $height . '+70);
this.moveTo((screen.width-' . $width . ')/2, (screen.height-' . $height . ')/2);
-->
</script>';
// generate XHTML with thumbnail and link to picture view.
$imgtag = '<img class="photos" src="' . $thumbpath . '" alt="' . $src . '"/>';
$output = $imgtag;
?>
<html>
示例4: generate_thumb
if (is_file($meta_file)) {
// Pull in meta information
include $meta_file;
if ($counter % 2 == 0) {
$table_row_color = 'color-1';
} else {
$table_row_color = 'color-2';
}
// Generate small preview thumb, update thumb if preview.png has been updated
$timestamp = @filemtime($theme_dir . $theme_folder_basename . '/preview.png');
$thumbnail_config[THUMB_THEME]['timestamp'] = $timestamp;
$thumbnail_config[THUMB_THEME]['size'] = 150;
$preview_thumb = generate_thumb($theme_folder_name . 'preview.png', $theme_name, THUMB_THEME);
// Generate large Lightbox preview thumb, update thumb if preview.png has been updated
$thumbnail_config[THUMB_THEME]['size'] = 500;
$preview_thumb_large = generate_thumb($theme_folder_name . 'preview.png', $theme_name . '-large', THUMB_THEME);
// Start a new table row (alternating colors)
if ($config['theme_dir'] == $theme_folder_basename) {
$table_class = 'activated';
} else {
$table_class = $table_row_color;
}
$output .= "\n\t\t\t" . '<tr class="' . $table_class . '">';
$output .= "\n\t\t\t\t" . '<td class="width-175">';
if ($preview_thumb) {
$output .= '<div class="img-shadow"><a rel="lightbox" href="' . $preview_thumb_large . '"><img src="' . $preview_thumb . '" alt="' . $theme_name . '" /></a></div>';
}
$output .= '</td>
<td class="align-left width-100"><strong>' . $theme_name . '</strong><br />Version ' . $version . '</td>
<td style="padding-right: 50px;">' . $description . '<br />• ' . plog_tr('Released under the') . ' ' . $license . '.</td>
<td class="align-left width-100"><a href="' . $url . '">' . $author . '</a></td>';
示例5: dirname
require_once dirname(dirname(__FILE__)) . '/plog-load-config.php';
require PLOGGER_DIR . 'plog-admin/plog-admin.php';
require_once PLOGGER_DIR . 'plog-admin/plog-admin-functions.php';
// This script will just show a small preview of the thumbnail in admin view if
// you can't differentiate the small pics.
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<body>';
$src = $_REQUEST['src'];
$picture = get_picture_by_id($src);
$id = $picture['id'];
$thumbpath = generate_thumb($picture['path'], $picture['id'], THUMB_LARGE);
$thumbdir = $config['basedir'] . 'plog-content/thumbs/lrg-$id-' . basename($picture['path']);
list($width, $height, $type, $attr) = getimagesize($thumbdir);
echo '
<script type="text/javascript">
<!--
this.resizeTo(' . $width . '+25,' . $height . '+70);
this.moveTo((screen.width-' . $width . ')/2, (screen.height-' . $height . ')/2);
-->
</script>';
// Generate XHTML with thumbnail and link to picture view
$imgtag = '<img class="photos" src="' . $thumbpath . '" alt="' . $src . '" />';
?>
<?php
echo $imgtag;
示例6: intval
<?php
// This is mostly an interface for the XML service to get thumbnail URLs
// without having to generate the thumb at the time that the URL is
// needed.
require "plog-functions.php";
require "plog-globals.php";
/**
* plog-thumb.php interface for XML service
*
* Purpose: Provide a link to a thumbnail for a picture even when the thumbnail
* may not have been generated yet.
*
* @param int id (required)
* @param int type (default 1, any of 1,2,3,4)
*/
if (!isset($_REQUEST["id"]) || intval($_REQUEST["id"]) == 0) {
exit;
}
if (!isset($_REQUEST["type"])) {
$_REQUEST["type"] = 1;
}
$query = "SELECT\r\n\t\t`path`,\r\n\t\t`id`\r\n\tFROM `plogger_pictures`\r\n\tWHERE `id`=" . intval($_REQUEST["id"]);
$result = run_query($query);
$thumb = mysql_fetch_assoc($result);
$thumb["type"] = intval($_REQUEST["type"]);
$path = generate_thumb($thumb["path"], $thumb["id"], $thumb["type"]);
header("Location: " . $path);
exit;
示例7: intval
*
* Purpose: Provide a link to a thumbnail for a picture even when the thumbnail
* may not have been generated yet.
*
* @param int id (required)
* @param int type (default 1, any of 1,2,3,4)
*/
if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) {
exit;
}
if (!isset($_REQUEST['type'])) {
$_REQUEST['type'] = 1;
}
$query = "SELECT `path`, `id` FROM `plogger_pictures` WHERE `id`=" . intval($_REQUEST['id']);
$result = run_query($query);
$thumb = mysqli_fetch_assoc($result);
$thumb['type'] = intval($_REQUEST['type']);
$path = generate_thumb($thumb['path'], $thumb['id'], $thumb['type']);
// Make sure the generated url and the browser url have the same domain syntax
$browser_www = strpos($_SERVER['HTTP_HOST'], 'www');
$thumb_www = strpos($path, 'www');
if ($browser_www !== $thumb_www) {
if ($browser_www === false) {
$path = str_replace('www', '', $path);
} else {
$path = str_replace('//', '//www.', $path);
}
}
close_db();
header('Location: ' . $path);
exit;
示例8: plog_edit_album_form
function plog_edit_album_form($album_id)
{
global $config, $thumbnail_config;
$album_id = intval($album_id);
$album = get_album_by_id($album_id);
$auto_graphic = $config['gallery_url'] . 'plog-admin/images/auto.gif';
$page = isset($_GET['plog_page']) ? '&plog_page=' . intval($_GET['plog_page']) : '';
$output = "\n\t\t" . '<form class="edit width-700" action="' . $_SERVER['PHP_SELF'] . '?level=albums&id=' . $album['parent_id'] . $page . '" method="post">';
$images = '<option class="thumboption" value="0" style="padding-left: 100px; background-image: url(' . $auto_graphic . ');">' . plog_tr('automatic') . '</option>';
$sql = "SELECT id, caption, path FROM " . PLOGGER_TABLE_PREFIX . "pictures p WHERE p.parent_album = '" . $album_id . "'";
$result = run_query($sql);
while ($row = $result->fetch()) {
$selected = $row['id'] == $album['thumbnail_id'] ? ' selected="selected"' : '';
$style = 'class="thumboption" style="padding-left: ' . ($thumbnail_config[THUMB_SMALL]['size'] + 5) . 'px; background-image: url(' . generate_thumb(SmartStripSlashes($row['path']), $row['id']) . ');"';
$images .= "\n\t\t\t\t" . '<option ' . $style . ' value="' . $row['id'] . '"' . $selected . '>';
$images .= !empty($row['caption']) ? SmartStripSlashes($row['caption']) : SmartStripSlashes(basename($row['path']));
$images .= "</option>";
}
$output .= "\n\t\t\t" . '<div>
<div class="strong">' . plog_tr('Edit Album Properties') . '</div>
<p>
<label class="strong" for="name" accesskey="n">' . plog_tr('<em>N</em>ame') . ':</label><br />
<input size="61" name="name" id="name" value="' . htmlspecialchars(SmartStripSlashes($album['name'])) . '" />
</p>
<p>
<label class="strong" for="description" accesskey="d">' . plog_tr('<em>D</em>escription') . ':</label><br />
<input size="61" name="description" id="description" value="' . htmlspecialchars(SmartStripSlashes($album['description'])) . '" />
</p>
<p>
<span class="strong">Thumbnail:</span><br />
<select name="thumbnail_id" class="thumbselect width-450" id="thumbselect" onchange="updateThumbPreview(this)">' . $images . '
</select>
<script type="text/javascript">updateThumbPreview(document.getElementById(\'thumbselect\'));</script>
</p>
<input type="hidden" name="pid" value="' . $album_id . '" />
<input type="hidden" name="action" value="update-album" />
<input class="submit" name="update" value="' . plog_tr('Update') . '" type="submit" />
<input class="submit-cancel" name="cancel" value="' . plog_tr('Cancel') . '" type="submit" />
</div>
</form>' . "\n";
return $output;
}
示例9: get_picture_by_id
$table_row_color = "color-1";
} else {
$table_row_color = "color-2";
}
// start a new table row (alternating colors)
$output .= "<tr class=\"{$table_row_color}\">";
// give the row a checkbox
$output .= '<td width="15"><input type="CHECKBOX" name="Selected[]" VALUE="' . $row["id"] . '"></td>';
// give the row a thumbnail, we need to look up the parent picture for the comment
$picture = get_picture_by_id($row["parent_id"]);
$thumbpath = generate_thumb($picture["path"], $picture["id"], THUMB_SMALL);
// generate XHTML with thumbnail and link to picture view.
$imgtag = '<div class="img-shadow"><img src="' . $thumbpath . '" title="' . $picture["caption"] . '" alt="' . $picture["caption"] . '" /></div>';
//$target = 'plog-thumbpopup.php?src='.$picture["id"];;
//$java = "javascript:this.ThumbPreviewPopup('$target')";
$output .= '<td><a href="' . generate_thumb($picture["path"], $picture["id"], THUMB_LARGE) . '" rel="lightbox" title="' . plogger_get_picture_caption() . '">' . $imgtag . '</a></td>';
foreach ($row as $key => $value) {
$value = htmlspecialchars($value);
$value = SmartStripSlashes($value);
if ($key == "unix_date") {
$output .= '<td>' . date($config["date_format"], $value) . '</td>';
} else {
if ($key == "allow_comments") {
if ($value) {
$output .= "<td>" . plog_tr('Yes') . "</td>";
} else {
$output .= "<td>" . plog_tr('No') . "</td>";
}
} else {
if (in_array($key, $allowedCommentKeys)) {
$output .= "<td><p id=\"comment-{$key}-" . $row[id] . "\">{$value} </p></td>";
示例10: list
$err = NULL;
// Short error code
list($src_width, $src_height) = imgsize($File->get_full_path());
if (!$resample_all_images && check_thumbnail_sizes($thumb_type, $thumb_width, $thumb_height, $src_width, $src_height)) {
// There is no need to resample, use original!
$err = $File->get_af_thumb_path($size_name, $mimetype, true, $size_x);
if ($err[0] != '!' && @copy($File->get_full_path(), $err)) {
// File was saved. Ouput that same file immediately:
// note: @copy returns FALSE on failure, if not muted it'll print the error on screen
$err = $File->output_cached_thumb($size_name, $mimetype, $mtime, $size_x);
}
} else {
// Resample
list($err, $src_imh) = load_image($File->get_full_path(), $mimetype);
if (empty($err)) {
list($err, $dest_imh) = generate_thumb($src_imh, $thumb_type, $thumb_width, $thumb_height, $thumb_percent_blur, $size_x);
if (empty($err)) {
$err = $File->save_thumb_to_cache($dest_imh, $size_name, $mimetype, $thumb_quality, $size_x);
if (empty($err)) {
// File was saved. Ouput that same file immediately:
// This is probably better than recompressing the memory image..
$err = $File->output_cached_thumb($size_name, $mimetype, $mtime, $size_x);
} else {
// File could not be saved.
// fp> We might want to output dynamically...
// $err = output_image( $dest_imh, $mimetype );
}
}
}
}
}
示例11: umask
continue;
}
if (!is_dir($realdir . $delim . $thumbdir)) {
$u = umask(0);
if (is_writable($realdir) !== TRUE) {
chmod($realdir, 0777);
}
if (!@mkdir($realdir . $delim . $thumbdir, 0777)) {
echo '<p style="color: red; text-align: center">' . word('mkdir_error') . '</span>';
break;
}
umask($u);
}
$thumb = $realdir . $delim . $thumbdir . $delim . $filename . '.thumb.jpg';
if (!is_file($thumb) || filemtime($file) > filemtime($thumb)) {
generate_thumb($thumb, $file);
}
if ($filenames) {
echo '<div>';
}
if ($included && $inline) {
echo '<a href="?';
if (array_key_exists('dir', $_REQUEST)) {
echo 'dir=' . urlencode($_REQUEST['dir']) . '&';
}
echo 'pic=' . $i . html($urlsuffix);
} else {
echo '<a href="' . html("{$dirnamehttp}/{$filename}");
}
echo '"><img src="' . html("{$dirnamehttp}/{$thumbdir}/{$filename}.thumb.jpg");
echo '" alt="' . html($filename) . '" style="';
示例12: thumbnail
/**
* This will spit out a content-type header followed by a thumbnail for this file.
*
* @todo a million things (fp) but you get the idea...
* The generated thumb will be saved to a cached file here (fp)
* The cache will be accessed through the File object (fp)
* @todo cleanup memory resources
*
* @param string requested size: 'thumbnail'
*/
function thumbnail($req_size)
{
load_funcs('/files/model/_image.funcs.php');
$size_name = $req_size;
switch ($req_size) {
case 'fit-720x500':
$thumb_width = 720;
$thumb_height = 500;
$thumb_quality = 90;
break;
case 'fit-640x480':
$thumb_width = 640;
$thumb_height = 480;
$thumb_quality = 90;
break;
case 'fit-400x320':
$thumb_width = 400;
$thumb_height = 320;
$thumb_quality = 85;
break;
case 'fit-320x320':
$thumb_width = 320;
$thumb_height = 320;
$thumb_quality = 85;
break;
case 'fit-80x80':
default:
$size_name = 'fit-80x80';
$thumb_width = 80;
$thumb_height = 80;
$thumb_quality = 75;
}
$mimetype = $this->Filetype->mimetype;
// Try to output the cached thumbnail:
$err = $this->output_cached_thumb($size_name, $mimetype);
if ($err == '!Thumbnail not found in .evocache') {
// The thumbnail wasn't already in the cache, try to generate and cache it now:
$err = NULL;
// Short error code
list($err, $src_imh) = load_image($this->get_full_path(), $mimetype);
if (empty($err)) {
list($err, $dest_imh) = generate_thumb($src_imh, $thumb_width, $thumb_height);
if (empty($err)) {
$err = $this->save_thumb_to_cache($dest_imh, $size_name, $mimetype, $thumb_quality);
if (empty($err)) {
// File was saved. Ouput that same file immediately:
// This is probably better than recompressing the memory image..
$err = $this->output_cached_thumb($size_name, $mimetype);
} else {
// File could not be saved.
// fp> We might want to output dynamically...
// $err = output_image( $dest_imh, $mimetype );
}
}
}
}
// ERROR IMAGE
if (!empty($err)) {
// Generate an error image and try to squeeze an error message inside:
// Note: we write small and close to the upper left in order to have as much text as possible on small thumbs
$err = substr($err, 1);
// crop 1st car
$car_width = ceil(($thumb_width - 4) / 6);
// $err = 'w='.$car_width.' '.$err;
$err = wordwrap($err, $car_width, "\n");
$err = split("\n", $err);
// split into lines
$im_handle = imagecreatetruecolor($thumb_width, $thumb_height);
// Create a black image
$text_color = imagecolorallocate($im_handle, 255, 0, 0);
$y = 0;
foreach ($err as $err_string) {
imagestring($im_handle, 2, 2, $y, $err_string, $text_color);
$y += 11;
}
header('Content-type: image/png');
imagepng($im_handle);
}
}
示例13: dirname
<?php
// This will create a picture thumbnail on disk
// First it will be used for import only.
// Load configuration variables from database, plog-globals, & plog-includes/plog-functions
require_once dirname(dirname(__FILE__)) . '/plog-load-config.php';
require_once PLOGGER_DIR . 'plog-admin/plog-admin-functions.php';
// Set up the default error message
$found = plog_tr('No such image');
if (empty($_GET['img'])) {
exit($found);
}
$files = get_files(PLOGGER_DIR . 'plog-content/uploads');
$up_dir = PLOGGER_DIR . 'plog-content/uploads';
foreach ($files as $file) {
if (md5($file) == $_GET['img']) {
$rname = substr($file, strlen($up_dir) + 1);
$thumbpath = generate_thumb($up_dir . '/' . $rname, 'import-' . substr(md5($file), 0, 2), THUMB_SMALL);
$found = '<img src="' . $thumbpath . '" alt="" /></div>';
//echo "found $relative_name!";
break;
}
}
close_db();
close_ftp();
echo $found;
示例14: plogger_get_album_thumb
function plogger_get_album_thumb()
{
$rv = $GLOBALS['current_album'];
// Figure out the thumbnail as well
$thumb_query = "SELECT * FROM \"" . PLOGGER_TABLE_PREFIX . "pictures\" WHERE ";
if ($rv['thumbnail_id'] > 0) {
$thumb_query .= " \"id\"=" . $rv['thumbnail_id'];
} else {
$thumb_query .= " \"parent_album\"='" . $rv['id'] . "' ORDER BY \"date_submitted\" DESC LIMIT 1";
}
$thumb_result = run_query($thumb_query);
$thumb_data = $thumb_result->fetch();
if ($thumb_data) {
$rv['thumbnail_id'] = $thumb_data['id'];
$rv['thumbnail_path'] = $thumb_data['path'];
}
return generate_thumb($rv['thumbnail_path'], $rv['thumbnail_id'], THUMB_SMALL);
}
示例15: mysqli_query
/* The database query to pull random images from a specific collection. Uncomment and change the X to the ID of the desired collection. */
//$plog_random_images_query = "SELECT * FROM ".PLOGGER_TABLE_PREFIX."pictures WHERE `parent_collection` = X ORDER BY RAND() LIMIT $plog_random_images_amount";
$plog_random_images_result = mysqli_query($GLOBALS["PLOGGER_DBH"], $plog_random_images_query) or die("Could not execute query: {$plog_random_images_query}." . mysqli_error($GLOBALS["PLOGGER_DBH"]));
$config['baseurl'] = $plog_random_images_site_url;
/* The loop */
while ($row = mysqli_fetch_array($plog_random_images_result)) {
$id = $row['id'];
$path = $row['path'];
$caption = SmartStripSlashes($row['caption']);
$name = substr(basename($row['path']), 0, strrpos(basename($row['path']), '.'));
$cap_or_name = !empty($caption) ? $caption : $name;
?>
<a href="<?php
echo generate_url('picture', $id);
?>
" title="<?php
echo addcslashes($cap_or_name, '"');
?>
"><img class="random-images-thumbnail" src="<?php
echo generate_thumb($path, $id);
?>
" alt="<?php
echo $name;
?>
" /></a><br />
<p class="random-images-caption"><?php
echo $caption;
?>
</p>
<?php
}