Skip to content

Commit

Permalink
Fix Bug #53185 (icon width/height adjustement for icons > 127px also …
Browse files Browse the repository at this point in the history
…applied on smilies) - related to r10088

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10234 89ea8834-ac86-4346-8a33-228a782c2dd0
  • Loading branch information
acydburn committed Oct 26, 2009
1 parent 6d1c40f commit 6ca7b21
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions phpBB/includes/acp/acp_icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,19 @@ function main($id, $mode)
continue;
}

// adjust the width and height to be lower than 128px while perserving the aspect ratio
if ($img_size[0] > 127 && $img_size[0] > $img_size[1])
// adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons)
if ($mode == 'icons')
{
$img_size[1] = (int) ($img_size[1] * (127 / $img_size[0]));
$img_size[0] = 127;
}
else if ($img_size[1] > 127)
{
$img_size[0] = (int) ($img_size[0] * (127 / $img_size[1]));
$img_size[1] = 127;
if ($img_size[0] > 127 && $img_size[0] > $img_size[1])
{
$img_size[1] = (int) ($img_size[1] * (127 / $img_size[0]));
$img_size[0] = 127;
}
else if ($img_size[1] > 127)
{
$img_size[0] = (int) ($img_size[0] * (127 / $img_size[1]));
$img_size[1] = 127;
}
}

$_images[$path . $img]['file'] = $path . $img;
Expand Down Expand Up @@ -363,7 +366,7 @@ function main($id, $mode)
if ($mode == 'smilies' && $action == 'create')
{
$smiley_count = $this->item_count($table);

$addable_smileys_count = sizeof($images);
foreach ($images as $image)
{
Expand All @@ -372,7 +375,7 @@ function main($id, $mode)
--$addable_smileys_count;
}
}

if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT)
{
trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING);
Expand Down Expand Up @@ -400,15 +403,19 @@ function main($id, $mode)
$image_height[$image] = $img_size[1];
}

if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image])
// Adjust image width/height for icons
if ($mode == 'icons')
{
$image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image]));
$image_width[$image] = 127;
}
else if ($image_height[$image] > 127)
{
$image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image]));
$image_height[$image] = 127;
if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image])
{
$image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image]));
$image_width[$image] = 127;
}
else if ($image_height[$image] > 127)
{
$image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image]));
$image_height[$image] = 127;
}
}

$img_sql = array(
Expand Down Expand Up @@ -923,7 +930,7 @@ function main($id, $mode)
generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)
);
}

/**
* Returns the count of smilies or icons in the database
*
Expand Down

0 comments on commit 6ca7b21

Please sign in to comment.