本文整理匯總了PHP中vB_Image::is_valid_thumbnail_extension方法的典型用法代碼示例。如果您正苦於以下問題:PHP vB_Image::is_valid_thumbnail_extension方法的具體用法?PHP vB_Image::is_valid_thumbnail_extension怎麽用?PHP vB_Image::is_valid_thumbnail_extension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vB_Image
的用法示例。
在下文中一共展示了vB_Image::is_valid_thumbnail_extension方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: switch
/**
* Attempt to resize file if the filesize is too large after an initial resize to max dimensions or the file is already within max dimensions but the filesize is too large
*
* @param bool Has the image already been resized once?
* @param bool Attempt a resize
*/
function fetch_best_resize(&$jpegconvert, $resize = true)
{
if (!$jpegconvert and $this->upload['filesize'] > $this->maxuploadsize and $resize and $this->image->is_valid_resize_type($this->imginfo[2])) {
// Linear Regression
switch ($this->registry->options['thumbquality']) {
case 65:
// No Sharpen
// $magicnumber = round(379.421 + .00348171 * $this->maxuploadsize);
// Sharpen
$magicnumber = round(277.652 + 0.00428902 * $this->maxuploadsize);
break;
case 85:
// No Sharpen
// $magicnumber = round(292.53 + .0027378 * $this-maxuploadsize);
// Sharpen
$magicnumber = round(189.939 + 0.00352439 * $this->maxuploadsize);
break;
case 95:
// No Sharpen
// $magicnumber = round(188.11 + .0022561 * $this->maxuploadsize);
// Sharpen
$magicnumber = round(159.146 + 0.00234146 * $this->maxuploadsize);
break;
default:
//75
// No Sharpen
// $magicnumber = round(328.415 + .00323415 * $this->maxuploadsize);
// Sharpen
$magicnumber = round(228.201 + 0.00396951 * $this->maxuploadsize);
}
$xratio = $this->imginfo[0] > $magicnumber ? $magicnumber / $this->imginfo[0] : 1;
$yratio = $this->imginfo[1] > $magicnumber ? $magicnumber / $this->imginfo[1] : 1;
if ($xratio > $yratio and $xratio != 1) {
$new_width = round($this->imginfo[0] * $xratio);
$new_height = round($this->imginfo[1] * $xratio);
} else {
$new_width = round($this->imginfo[0] * $yratio);
$new_height = round($this->imginfo[1] * $yratio);
}
if ($new_width == $this->imginfo[0] and $new_height == $this->imginfo[1]) {
// subtract one pixel so that requested size isn't the same as the image size
$new_width--;
$forceresize = false;
} else {
$forceresize = true;
}
$this->upload['resized'] = $this->image->fetch_thumbnail($this->upload['filename'], $this->upload['location'], $new_width, $new_height, $this->registry->options['thumbquality'], false, false, true, false);
if (empty($this->upload['resized']['filedata'])) {
if ($this->image->is_valid_thumbnail_extension(file_extension($this->upload['filename'])) and !empty($this->upload['resized']['imageerror']) and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
if (($error = $this->image->fetch_error()) !== false and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
$this->set_error('image_resize_failed_x', htmlspecialchars_uni($error));
return false;
} else {
$this->set_error($this->upload['resized']['imageerror']);
return false;
}
} else {
$this->set_error('upload_file_exceeds_forum_limit', vb_number_format($this->upload['filesize'], 1, true), vb_number_format($this->maxuploadsize, 1, true));
#$this->set_error('upload_exceeds_dimensions', $this->maxwidth, $this->maxheight, $this->imginfo[0], $this->imginfo[1]);
return false;
}
} else {
$jpegconvert = true;
}
}
if (!$jpegconvert and $this->upload['filesize'] > $this->maxuploadsize) {
$this->set_error('upload_file_exceeds_forum_limit', vb_number_format($this->upload['filesize'], 1, true), vb_number_format($this->maxuploadsize, 1, true));
return false;
} else {
if ($jpegconvert and $this->upload['resized']['filesize'] and ($this->upload['resized']['filesize'] > $this->maxuploadsize or $forceresize)) {
$ratio = $this->maxuploadsize / $this->upload['resized']['filesize'];
$newwidth = $this->upload['resized']['width'] * sqrt($ratio);
$newheight = $this->upload['resized']['height'] * sqrt($ratio);
if ($newwidth > $this->imginfo[0]) {
$newwidth = $this->imginfo[0] - 1;
}
if ($newheight > $this->imginfo[1]) {
$newheight = $this->imginfo[1] - 1;
}
$this->upload['resized'] = $this->image->fetch_thumbnail($this->upload['filename'], $this->upload['location'], $newwidth, $newheight, $this->registry->options['thumbquality'], false, false, true, false);
if (empty($this->upload['resized']['filedata'])) {
if (!empty($this->upload['resized']['imageerror']) and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
if (($error = $this->image->fetch_error()) !== false and $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
$this->set_error('image_resize_failed_x', htmlspecialchars_uni($error));
return false;
} else {
$this->set_error($this->upload['resized']['imageerror']);
return false;
}
} else {
$this->set_error('upload_file_exceeds_forum_limit', vb_number_format($this->upload['filesize'], 1, true), vb_number_format($this->maxuploadsize, 1, true));
#$this->set_error('upload_exceeds_dimensions', $this->maxwidth, $this->maxheight, $this->imginfo[0], $this->imginfo[1]);
return false;
}
//.........這裏部分代碼省略.........