Skip to content

Commit

Permalink
#138: Fixed black background from PNGs that are uploaded as user prof…
Browse files Browse the repository at this point in the history
…ile pictures.
  • Loading branch information
JuanMenendezBuitrago committed May 22, 2015
1 parent 8564986 commit a8d87a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions TGD/protected/extensions/jcrop/EJCropper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public function crop($src, array $coords)
return false;
}
$dest_r = imagecreatetruecolor($this->targ_w, $this->targ_h);
imagealphablending( $dest_r, false );
imagesavealpha( $dest_r, true );
if (!imagecopyresampled($dest_r, $img, 0, 0, $coords['x'], $coords['y'], $this->targ_w, $this->targ_h, $coords['w'], $coords['h'])) {
return false;
}
Expand Down
9 changes: 3 additions & 6 deletions TGD/protected/models/Members.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ public function getOurPeople(){
SELECT id, username, avatar, url, seniority_level
FROM tbl_members
WHERE avatar IS NOT NULL AND avatar != '' AND status = 2 AND superuser != 1
ORDER BY seniority_level DESC, RANDOM();
")
ORDER BY seniority_level DESC, RANDOM();")
->queryAll();

$http = (empty($_SERVER['HTTPS'])) ? 'http' : 'https';


if(!empty($users)){
foreach($users as $key => $user) {
if(!@getimagesize( "$http://" . $_SERVER['HTTP_HOST'] . "/uploads/avatars/" . $user['id'] . "/thumb/" . $user['avatar'])) {
if(!file_exists(Yii::app()->basePath ."/../uploads/avatars/" . $user['id'] . "/thumb/" . $user['avatar'])) {
unset($users[$key]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion TGD/protected/views/site/company.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<?php foreach($people[0] as $key => $member) : ?>
<div class="col-sm-3 col-md-3 col-lg-3 col-xs-3 <?php if($key%5 == 0 ) echo 'our_people_margin';?>">
<?php
$img = CHtml::image(Yii::app()->baseUrl."/uploads/avatars/".$member['id']."/thumb/".$member['avatar'], '', array('class'=>'thumbnail ' . $arr[$member['seniority_level']], 'style' => 'background-color:'.$colors[$member['seniority_level']]));
$img = CHtml::image(Yii::app()->baseUrl."/uploads/avatars/".$member['id']."/thumb/".$member['avatar'], '', array('class'=>'thumbnail ' . $arr[$member['seniority_level']], 'style' => 'border:2px solid '.$colors[$member['seniority_level']]));
if(empty($member['url']))
echo $img;
else
Expand Down
6 changes: 4 additions & 2 deletions TGD/themes/tgd/js/profile-crop.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ $(document).ready(function(){

$(window).load(function() {
jcrop_api = $.Jcrop('#profile_crop', {
aspectRatio: 1
aspectRatio: 1,
bgColor : 'transparent'
});
});

Expand Down Expand Up @@ -96,7 +97,8 @@ function show_crop(data){
onChange: showPreview,
onSelect: showPreview,
setSelect: [0, 0, default_width, image_height],
aspectRatio: 1
aspectRatio: 1,
bgColor : 'transparent'
});

$('.jcrop-holder').addClass('thumbnail');
Expand Down

0 comments on commit a8d87a1

Please sign in to comment.