mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Fixed admin logo upload
This commit is contained in:
parent
87885cea32
commit
d899717d2c
@ -3,6 +3,8 @@
|
||||
namespace humhub\libs;
|
||||
|
||||
use Yii;
|
||||
use yii\web\UploadedFile;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class LogoImage
|
||||
{
|
||||
@ -19,7 +21,7 @@ class LogoImage
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,13 +35,12 @@ class LogoImage
|
||||
$path = "";
|
||||
|
||||
// Workaround for absolute urls in console applications (Cron)
|
||||
if (Yii::app() instanceof CConsoleApplication) {
|
||||
$path = Yii::app()->request->getBaseUrl();
|
||||
if (Yii::$app->request->isConsoleRequest) {
|
||||
$path = Url::base(true);
|
||||
} else {
|
||||
$path = Yii::app()->getBaseUrl(true);
|
||||
$path = Url::base();
|
||||
}
|
||||
|
||||
|
||||
if (file_exists($this->getPath())) {
|
||||
$path .= '/uploads/' . $this->folder_images . '/logo.png';
|
||||
}
|
||||
@ -82,9 +83,9 @@ class LogoImage
|
||||
public function setNew(UploadedFile $file)
|
||||
{
|
||||
$this->delete();
|
||||
move_uploaded_file($file->getTempName(), $this->getPath());
|
||||
move_uploaded_file($file->tempName, $this->getPath());
|
||||
|
||||
ImageConverter::Resize($this->getPath(), $this->getPath(), array('height' => $this->height, 'width' => 0, 'mode' => 'max', 'transparent' => ($file->getExtensionName() == 'png' && ImageConverter::checkTransparent($this->getPath()))));
|
||||
ImageConverter::Resize($this->getPath(), $this->getPath(), array('height' => $this->height, 'width' => 0, 'mode' => 'max', 'transparent' => ($file->getExtension() == 'png' && ImageConverter::checkTransparent($this->getPath()))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,8 @@ use humhub\compat\CActiveForm;
|
||||
use humhub\compat\CHtml;
|
||||
use humhub\models\Setting;
|
||||
use yii\helpers\Url;
|
||||
|
||||
$this->registerJsFile('@web/resources/admin/uploadLogo.js');
|
||||
?>
|
||||
<div class="panel panel-default">
|
||||
<div
|
||||
@ -67,7 +69,7 @@ use yii\helpers\Url;
|
||||
'linkContent' => '<i class="fa fa-times"></i>',
|
||||
'cssClass' => 'btn btn-danger btn-sm',
|
||||
'style' => $logo->hasImage() ? '' : 'display: none;',
|
||||
'linkHref' => Url::toRoute("/admin/setting/deleteLogoImage"),
|
||||
'linkHref' => Url::toRoute("/admin/setting/delete-logo-image"),
|
||||
'confirmJS' => 'function(jsonResp) { resetLogoImage(jsonResp); }'
|
||||
));
|
||||
?>
|
||||
|
@ -1,6 +1,4 @@
|
||||
function resetLogoImage(jsonResp) {
|
||||
|
||||
json = jQuery.parseJSON(jsonResp);
|
||||
function resetLogoImage(json) {
|
||||
$('#deleteLinkPost_modal_logoimagedelete').hide();
|
||||
$('#logo-image').attr('src', '');
|
||||
$('#img-logo').hide();
|
||||
|
Loading…
x
Reference in New Issue
Block a user