Skip to content

Commit

Permalink
more webp
Browse files Browse the repository at this point in the history
  • Loading branch information
albertlast committed Sep 3, 2023
1 parent 37eae50 commit 20c391e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Sources/ManageLanguages.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function DownloadLanguage()
$extension = $pathinfo['extension'];

// Don't do anything with files we don't understand.
if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt')))
if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt', 'webp')))
continue;

// Basic data.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ManageMembergroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ function EditMembergroup()
}

// Get a list of all the image formats we can select.
$imageExts = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
$imageExts = array('png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp');

// Scan the directory.
$context['possible_icons'] = array();
Expand Down
2 changes: 1 addition & 1 deletion Sources/Packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ function ExamineFile()
$context['filename'] = $_REQUEST['file'];

// Let the unpacker do the work.... but make sure we handle images properly.
if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png')))
if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png', '.webp')))
$context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">';
else
{
Expand Down
5 changes: 3 additions & 2 deletions Sources/Profile-Modify.php
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ function getAvatars($directory, $level)
$extension = substr(strrchr($line, '.'), 1);

// Make sure it is an image.
if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0 && strcasecmp($extension, 'webp') != 0)
continue;

$result[] = array(
Expand Down Expand Up @@ -3660,7 +3660,8 @@ function profileSaveAvatarData(&$value)
'1' => 'gif',
'2' => 'jpg',
'3' => 'png',
'6' => 'bmp'
'6' => 'bmp',
'18' => 'webp'
);

$extension = isset($extensions[$sizes[2]]) ? $extensions[$sizes[2]] : 'bmp';
Expand Down
8 changes: 6 additions & 2 deletions Sources/Subs-Graphics.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ function resizeImageFile($source, $destination, $max_width, $max_height, $prefer
'2' => 'jpeg',
'3' => 'png',
'6' => 'bmp',
'15' => 'wbmp'
'15' => 'wbmp',
'18' => 'webp'
);

// Get the image file, we have to work with something after all
Expand Down Expand Up @@ -428,7 +429,8 @@ function resizeImage($src_img, $destName, $src_width, $src_height, $max_width, $
'2' => 'jpeg',
'3' => 'png',
'6' => 'bmp',
'15' => 'wbmp'
'15' => 'wbmp',
'18' => 'webp'
);
$preferred_format = empty($preferred_format) || !isset($default_formats[$preferred_format]) ? 2 : $preferred_format;

Expand Down Expand Up @@ -563,6 +565,8 @@ function resizeImage($src_img, $destName, $src_width, $src_height, $max_width, $
$success = imagebmp($dst_img, $destName);
elseif (!empty($preferred_format) && ($preferred_format == 15) && function_exists('imagewbmp'))
$success = imagewbmp($dst_img, $destName);
elseif (!empty($preferred_format) && ($preferred_format == 18) && function_exists('imagewebp'))
$success = imagewebp($dst_img, $destName);
elseif (function_exists('imagejpeg'))
$success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);

Expand Down
2 changes: 1 addition & 1 deletion Sources/Subs-Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ function get_file_listing($path, $relative)
'is_writable' => is_writable($path . '/' . $entry),
'is_directory' => false,
'is_template' => preg_match('~\.template\.php$~', $entry) != 0,
'is_image' => preg_match('~\.(jpg|jpeg|gif|bmp|png)$~', $entry) != 0,
'is_image' => preg_match('~\.(jpg|jpeg|gif|bmp|png|webp)$~', $entry) != 0,
'is_editable' => is_writable($path . '/' . $entry) && preg_match('~\.(php|pl|css|js|vbs|xml|xslt|txt|xsl|html|htm|shtm|shtml|asp|aspx|cgi|py)$~', $entry) != 0,
'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;filename=' . $relative . $entry,
'size' => $size,
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/Profile.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -2991,7 +2991,7 @@ function template_profile_avatar_select()
echo '
<div id="avatar_upload">
', $context['member']['avatar']['choice'] == 'upload' ? '<div class="edit_avatar_img"><img src="' . $context['member']['avatar']['href'] . '" alt=""></div>' : '', '
<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png, image/webp">', template_max_size('upload'), '
', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
</div>';

Expand Down

0 comments on commit 20c391e

Please sign in to comment.