Browse Source

Fix avatar upload

pull/1058/head
Timothée Jaussoin 4 years ago
parent
commit
69cfe26104
  1. 8
      app/widgets/Avatar/Avatar.php
  2. 5
      app/widgets/CommunityConfig/CommunityConfig.php
  3. 2
      app/widgets/CommunityConfig/_communityconfig_avatar.tpl
  4. 2
      src/Movim/Image.php

8
app/widgets/Avatar/Avatar.php

@ -64,18 +64,18 @@ class Avatar extends \Movim\Widget\Base
public function ajaxSubmit($avatar)
{
$tempKey = \generateKey(6);
$p = new Image;
$p->fromBase($avatar->photobin->value);
$p->setKey($tempKey);
$p->setKey($this->user->id.'avatar');
$p->save(false, false, 'jpeg', 60);
// Reload
$p->load();
$p->load('jpeg');
$r = new Set;
$r->setData($p->toBase())->request();
$p->remove();
$p->remove('jpeg');
}
}

5
app/widgets/CommunityConfig/CommunityConfig.php

@ -85,13 +85,14 @@ class CommunityConfig extends Base
$p->save(false, false, 'jpeg', 60);
// Reload the freshly compressed picture
$p->load();
$p->load('jpeg');
$r = new AvatarSet;
$r->setTo($origin)
->setNode($node)
->setUrl(Image::getOrCreate($key, false, false, 'jpeg', true))
->setData($p->toBase())->request();
->setData($p->toBase())
->request();
}
public function ajaxGetConfig($origin, $node, $advanced = false)

2
app/widgets/CommunityConfig/_communityconfig_avatar.tpl

@ -1,6 +1,6 @@
<section class="scroll">
<form name="avatarcommunity">
<img class="avatar" src="{$info->getPhoto('o')}">
<img class="avatar" src="{$info->getPhoto('o') ?? ''}">
<div class="placeholder">
<i class="material-icons">image</i>
<h1>{$c->__('avatar.missing')}</h1>

2
src/Movim/Image.php

@ -204,7 +204,7 @@ class Image
$this->_im->setInterlaceScheme(\Imagick::INTERLACE_PLANE);
// Put 11 as a value for now, see http://php.net/manual/en/imagick.flattenimages.php#116956
$this->_im->setImageAlphaChannel(Imagick::ALPHACHANNEL_REMOVE);
$this->_im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE);
//$this->_im->setImageAlphaChannel(11);
$this->_im->setImageBackgroundColor('#ffffff');
}

Loading…
Cancel
Save