[ticket/16899] Add SVG and WEBP image type to ranks, smilies and topic icons

PHPBB3-16899
This commit is contained in:
3D-I 2021-10-21 21:47:14 +02:00
parent 99734fc648
commit afbf7aadd2
4 changed files with 26 additions and 18 deletions

View file

@ -91,29 +91,33 @@ class acp_icons
{ {
$img_size = getimagesize($phpbb_root_path . $img_path . '/' . $path . $img); $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $path . $img);
if (!$img_size[0] || !$img_size[1] || strlen($img) > 255) if ($img_size)
{ {
continue; if (!$img_size[0] || !$img_size[1] || strlen($img) > 255)
}
// adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons)
if ($mode == 'icons')
{
if ($img_size[0] > 127 && $img_size[0] > $img_size[1])
{ {
$img_size[1] = (int) ($img_size[1] * (127 / $img_size[0])); continue;
$img_size[0] = 127;
} }
else if ($img_size[1] > 127)
// adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons)
if ($mode == 'icons')
{ {
$img_size[0] = (int) ($img_size[0] * (127 / $img_size[1])); if ($img_size[0] > 127 && $img_size[0] > $img_size[1])
$img_size[1] = 127; {
$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; $_images[$path . $img]['file'] = $path . $img;
$_images[$path . $img]['width'] = $img_size[0];
$_images[$path . $img]['height'] = $img_size[1]; $_images[$path . $img]['width'] = $img_size ? $img_size[0] : '';
$_images[$path . $img]['height'] = $img_size ? $img_size[1] : '';
} }
} }
unset($imglist); unset($imglist);

View file

@ -55,8 +55,8 @@ class acp_ranks
$min_posts = ($special_rank) ? 0 : max(0, $request->variable('min_posts', 0)); $min_posts = ($special_rank) ? 0 : max(0, $request->variable('min_posts', 0));
$rank_image = $request->variable('rank_image', ''); $rank_image = $request->variable('rank_image', '');
// The rank image has to be a jpg, gif or png // The rank image has to be a jp(e)g, gif, png, svg or webp
if ($rank_image != '' && !preg_match('#(\.gif|\.png|\.jpg|\.jpeg)$#i', $rank_image)) if ($rank_image != '' && !preg_match('#(\.gif|\.png|\.jpg|\.jpeg|\.svg|\.webp)$#i', $rank_image))
{ {
$rank_image = ''; $rank_image = '';
} }

View file

@ -479,7 +479,7 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm
/** /**
* Get physical file listing * Get physical file listing
*/ */
function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png|svg|webp')
{ {
$matches = array($dir => array()); $matches = array($dir => array());

View file

@ -735,6 +735,10 @@ fieldset.polls dd div {
margin-bottom: 10px; margin-bottom: 10px;
} }
.profile-rank img {
max-width: 160px;
}
/* Post-profile avatars */ /* Post-profile avatars */
.postprofile .has-avatar .avatar-container { .postprofile .has-avatar .avatar-container {
margin-bottom: 3px; margin-bottom: 3px;