本文整理匯總了PHP中ImageManager::isRealImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImageManager::isRealImage方法的具體用法?PHP ImageManager::isRealImage怎麽用?PHP ImageManager::isRealImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ImageManager
的用法示例。
在下文中一共展示了ImageManager::isRealImage方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isPicture
/**
* @deprecated 1.5.0
*/
function isPicture($file, $types = null)
{
Tools::displayAsDeprecated();
return ImageManager::isRealImage($file['tmp_name'], $file['type'], $types);
}
示例2: ajaxProcessUploadLogo
public function ajaxProcessUploadLogo()
{
if (!$this->access('edit')) {
die('<return result="error" message="' . $this->trans('You do not have permission to use this wizard.', array(), 'Admin.Shipping.Notification') . '" />');
}
$allowedExtensions = array('jpeg', 'gif', 'png', 'jpg');
$logo = isset($_FILES['carrier_logo_input']) ? $_FILES['carrier_logo_input'] : false;
if ($logo && !empty($logo['tmp_name']) && $logo['tmp_name'] != 'none' && (!isset($logo['error']) || !$logo['error']) && preg_match('/\\.(jpe?g|gif|png)$/', $logo['name']) && is_uploaded_file($logo['tmp_name']) && ImageManager::isRealImage($logo['tmp_name'], $logo['type'])) {
$file = $logo['tmp_name'];
do {
$tmp_name = uniqid() . '.jpg';
} while (file_exists(_PS_TMP_IMG_DIR_ . $tmp_name));
if (!ImageManager::resize($file, _PS_TMP_IMG_DIR_ . $tmp_name)) {
die('<return result="error" message="Impossible to resize the image into ' . Tools::safeOutput(_PS_TMP_IMG_DIR_) . '" />');
}
@unlink($file);
die('<return result="success" message="' . Tools::safeOutput(_PS_TMP_IMG_ . $tmp_name) . '" />');
} else {
die('<return result="error" message="Cannot upload file" />');
}
}
示例3: validateUpload
/**
* Validate image upload (check image type and weight)
*
* @param array $file Upload $_FILE value
* @param integer $max_file_size Maximum upload size
* @return bool|string Return false if no error encountered
*/
public static function validateUpload($file, $max_file_size = 0)
{
if ((int) $max_file_size > 0 && $file['size'] > (int) $max_file_size) {
return sprintf(Tools::displayError('Image is too large (%1$d kB). Maximum allowed: %2$d kB'), $file['size'] / 1000, $max_file_size / 1000);
}
if (!ImageManager::isRealImage($file['tmp_name'], $file['type']) || !ImageManager::isCorrectImageFileExt($file['name'])) {
return Tools::displayError('Image format not recognized, allowed formats are: .gif, .jpg, .png');
}
if ($file['error']) {
return sprintf(Tools::displayError('Error while uploading image; please change your server\'s settings. (Error code: %s)'), $file['error']);
}
return false;
}
示例4: _postValidation
private function _postValidation()
{
$yalign = Tools::getValue('yalign');
$xalign = Tools::getValue('xalign');
$transparency = (int) Tools::getValue('transparency');
$image_types = Tools::getValue('image_types');
if (empty($transparency)) {
$this->_postErrors[] = $this->l('Transparency required.');
} elseif ($transparency < 0 || $transparency > 100) {
$this->_postErrors[] = $this->l('Transparency is not in allowed range.');
}
if (empty($yalign)) {
$this->_postErrors[] = $this->l('Y-Align is required.');
} elseif (!in_array($yalign, $this->yaligns)) {
$this->_postErrors[] = $this->l('Y-Align is not in allowed range.');
}
if (empty($xalign)) {
$this->_postErrors[] = $this->l('X-Align is required.');
} elseif (!in_array($xalign, $this->xaligns)) {
$this->_postErrors[] = $this->l('X-Align is not in allowed range.');
}
if (empty($image_types)) {
$this->_postErrors[] = $this->l('At least one image type is required.');
}
if (isset($_FILES['PS_WATERMARK']['tmp_name']) && !empty($_FILES['PS_WATERMARK']['tmp_name'])) {
if (!ImageManager::isRealImage($_FILES['PS_WATERMARK']['tmp_name'], $_FILES['PS_WATERMARK']['type'], array('image/gif'))) {
$this->_postErrors[] = $this->l('Image must be in GIF format.');
}
}
return !count($this->_postErrors) ? true : false;
}
示例5: _postValidation
private function _postValidation()
{
$yalign = Tools::getValue('yalign');
$xalign = Tools::getValue('xalign');
$transparency = (int) Tools::getValue('transparency');
$types = ImageType::getImagesTypes('products');
$id_image_type = array();
foreach ($types as $type) {
if (!is_null(Tools::getValue('WATERMARK_TYPES_' . (int) $type['id_image_type']))) {
$id_image_type['WATERMARK_TYPES_' . (int) $type['id_image_type']] = true;
}
}
if (empty($transparency)) {
$this->_postErrors[] = $this->l('Opacity required.');
} elseif ($transparency < 1 || $transparency > 100) {
$this->_postErrors[] = $this->l('Opacity is not in allowed range.');
}
if (empty($yalign)) {
$this->_postErrors[] = $this->l('Y-Align is required.');
} elseif (!in_array($yalign, $this->yaligns)) {
$this->_postErrors[] = $this->l('Y-Align is not in allowed range.');
}
if (empty($xalign)) {
$this->_postErrors[] = $this->l('X-Align is required.');
} elseif (!in_array($xalign, $this->xaligns)) {
$this->_postErrors[] = $this->l('X-Align is not in allowed range.');
}
if (!count($id_image_type)) {
$this->_postErrors[] = $this->l('At least one image type is required.');
}
if (isset($_FILES['PS_WATERMARK']['tmp_name']) && !empty($_FILES['PS_WATERMARK']['tmp_name'])) {
if (!ImageManager::isRealImage($_FILES['PS_WATERMARK']['tmp_name'], $_FILES['PS_WATERMARK']['type'], array('image/gif'))) {
$this->_postErrors[] = $this->l('Image must be in GIF format.');
}
}
return !count($this->_postErrors) ? true : false;
}