本文整理汇总了PHP中SimpleImage::resizeOriginal方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleImage::resizeOriginal方法的具体用法?PHP SimpleImage::resizeOriginal怎么用?PHP SimpleImage::resizeOriginal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleImage
的用法示例。
在下文中一共展示了SimpleImage::resizeOriginal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadAvatar
//.........这里部分代码省略.........
$file['name'] = $my->id . '_' . JFile::makeSafe(md5($file['name'] . $date->toMySQL())) . '.' . strtolower($file_ext);
if (isset($file['name'])) {
$target_file_path = $upload_path;
$relative_target_file = $rel_upload_path . '/' . $file['name'];
$target_file = JPath::clean($target_file_path . '/' . JFile::makeSafe($file['name']));
$original = JPath::clean($target_file_path . '/' . 'original_' . JFile::makeSafe($file['name']));
$isNew = false;
require_once DISCUSS_HELPERS . '/image.php';
require_once DISCUSS_CLASSES . '/simpleimage.php';
if (!DiscussImageHelper::canUpload($file, $err)) {
if (!$isFromBackend) {
DiscussHelper::setMessageQueue(JText::_($err), 'error');
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&layout=edit', false));
} else {
// From backend
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=users', false), JText::_($err), 'error');
}
return;
}
if (0 != (int) $file['error']) {
if (!$isFromBackend) {
DiscussHelper::setMessageQueue($file['error'], 'error');
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&layout=edit', false));
} else {
//from backend
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=users', false), $file['error'], 'error');
}
return;
}
//rename the file 1st.
$oldAvatar = $profile->avatar;
$tempAvatar = '';
if ($oldAvatar != 'default.png') {
$session = JFactory::getSession();
$sessionId = $session->getToken();
$fileExt = JFile::getExt(JPath::clean($target_file_path . '/' . $oldAvatar));
$tempAvatar = JPath::clean($target_file_path . '/' . $sessionId . '.' . $fileExt);
// Test if old original file exists.
if (JFile::exists($target_file_path . '/original_' . $oldAvatar)) {
JFile::delete($target_file_path . '/original_' . $oldAvatar);
}
JFile::move($target_file_path . '/' . $oldAvatar, $tempAvatar);
} else {
$isNew = true;
}
if (JFile::exists($target_file)) {
if ($oldAvatar != 'default.png') {
//rename back to the previous one.
JFile::move($tempAvatar, $target_file_path . '/' . $oldAvatar);
}
if (!$isFromBackend) {
DiscussHelper::setMessageQueue(JText::sprintf('COM_EASYDISCUSS_FILE_ALREADY_EXISTS', $relative_target_file), 'error');
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=profile', false));
} else {
//from backend
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=users', false), JText::sprintf('COM_EASYDISCUSS_FILE_ALREADY_EXISTS', $relative_target_file), 'error');
}
return;
}
if (JFolder::exists($target_file)) {
if ($oldAvatar != 'default.png') {
//rename back to the previous one.
JFile::move($tempAvatar, $target_file_path . '/' . $oldAvatar);
}
if (!$isFromBackend) {
DiscussHelper::setMessageQueue(JText::sprintf('COM_EASYDISCUSS_FILE_ALREADY_EXISTS', $relative_target_file), 'error');
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=profile', false));
} else {
//from backend
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=users', false), JText::sprintf('COM_EASYDISCUSS_FILE_ALREADY_EXISTS', $relative_target_file), 'error');
}
return;
}
$configImageWidth = $config->get('layout_avatarwidth', 160);
$configImageHeight = $config->get('layout_avatarheight', 160);
$originalImageWidth = $config->get('layout_originalavatarwidth', 400);
$originalImageHeight = $config->get('layout_originalavatarheight', 400);
// Copy the original image files over
$image = new SimpleImage();
$image->load($file['tmp_name']);
//$image->resizeToFill( $originalImageWidth , $originalImageHeight );
// By Kevin Lankhorst
$image->resizeOriginal($originalImageWidth, $originalImageHeight, $configImageWidth, $configImageHeight);
$image->save($original, $image->image_type);
unset($image);
$image = new SimpleImage();
$image->load($file['tmp_name']);
$image->resizeToFill($configImageWidth, $configImageHeight);
$image->save($target_file, $image->image_type);
//now we update the user avatar. If needed, we remove the old avatar.
if ($oldAvatar != 'default.png') {
if (JFile::exists($tempAvatar)) {
JFile::delete($tempAvatar);
}
}
return JFile::makeSafe($file['name']);
} else {
return 'default.png';
}
}