mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-07 16:24:43 +03:00
parent
ef5c919803
commit
a99a839998
@ -101,8 +101,12 @@ class ButtonCodeController extends AbstractController
|
||||
: $image_locales[0];
|
||||
}
|
||||
|
||||
$file = MIBEW_FS_ROOT . '/locales/${lang}/button/${image}_on.png';
|
||||
if (!is_readable($file)) {
|
||||
// Fallback to .gif image
|
||||
$file = MIBEW_FS_ROOT . '/locales/${lang}/button/${image}_on.gif';
|
||||
$size = get_gifimage_size($file);
|
||||
}
|
||||
$size = get_image_size($file);
|
||||
|
||||
$image_link_args = array(
|
||||
'i' => $image,
|
||||
|
@ -80,7 +80,13 @@ class ButtonController extends AbstractController
|
||||
|
||||
// Get image file content
|
||||
$image_postfix = has_online_operators($group_id) ? "on" : "off";
|
||||
$file_name = "locales/${lang}/button/${image}_${image_postfix}.png";
|
||||
$content_type = 'image/png';
|
||||
if (!is_readable($file_name)) {
|
||||
// Fall back to .gif image
|
||||
$file_name = "locales/${lang}/button/${image}_${image_postfix}.gif";
|
||||
$content_type = 'image/gif';
|
||||
}
|
||||
|
||||
$fh = fopen($file_name, 'rb');
|
||||
if ($fh) {
|
||||
@ -91,7 +97,7 @@ class ButtonController extends AbstractController
|
||||
$response = new Response($content, 200);
|
||||
|
||||
// Set correct content info
|
||||
$response->headers->set('Content-Type', 'image/gif');
|
||||
$response->headers->set('Content-Type', $content_type);
|
||||
$response->headers->set('Content-Length', $file_size);
|
||||
} else {
|
||||
$response = new Response('Not found', 404);
|
||||
|
@ -15,12 +15,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
function get_gifimage_size($filename)
|
||||
function get_image_size($filename)
|
||||
{
|
||||
if (function_exists('gd_info')) {
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
|
||||
if (function_exists('gd_info') && ($ext == 'gif' || $ext == 'png')) {
|
||||
$info = gd_info();
|
||||
if (isset($info['GIF Read Support']) && $info['GIF Read Support']) {
|
||||
|
||||
$img = false;
|
||||
if ($ext == 'gif' && !empty($info['GIF Read Support'])) {
|
||||
$img = @imagecreatefromgif($filename);
|
||||
} elseif ($ext == 'png' && !empty($info['PNG Support'])) {
|
||||
$img = @imagecreatefrompng($filename);
|
||||
}
|
||||
|
||||
if ($img) {
|
||||
$height = imagesy($img);
|
||||
$width = imagesx($img);
|
||||
@ -29,7 +37,6 @@ function get_gifimage_size($filename)
|
||||
return array($width, $height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(0, 0);
|
||||
}
|
||||
|
@ -190,8 +190,8 @@ function get_image_locales_map($locales_dir)
|
||||
$images_dir = "$locales_dir/$curr/button";
|
||||
if ($handle = @opendir($images_dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
$both_files_exist = preg_match("/^(\w+)_on.gif$/", $file, $matches)
|
||||
&& is_file("$images_dir/" . $matches[1] . "_off.gif");
|
||||
$both_files_exist = preg_match("/^(\w+)_on\.(gif|png)$/", $file, $matches)
|
||||
&& is_file("$images_dir/" . $matches[1] . "_off." . $matches[2]);
|
||||
if ($both_files_exist) {
|
||||
$image = $matches[1];
|
||||
if (!isset($image_locales[$image])) {
|
||||
|
Loading…
Reference in New Issue
Block a user