set default thumbnail size to 64px and fix IDE warnings

This commit is contained in:
Ralf Becker 2014-12-11 09:57:31 +00:00
parent f0b2131cfd
commit 0b8ad9798c
2 changed files with 17 additions and 23 deletions

View File

@ -81,7 +81,7 @@ function get_app()
*/ */
function get_maxsize() function get_maxsize()
{ {
$preset = (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] == '' ? 32 : $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 :
$GLOBALS['egw_info']['server']['link_list_thumbnail']; $GLOBALS['egw_info']['server']['link_list_thumbnail'];
// Another maximum size may be passed if thumbnails are turned on // Another maximum size may be passed if thumbnails are turned on
@ -97,7 +97,7 @@ function get_maxsize()
* Either loads the thumbnail for the given file form cache or generates a new * Either loads the thumbnail for the given file form cache or generates a new
* one * one
* *
* @param string $file is the file of which a thumbnail should be created * @param string $src is the file of which a thumbnail should be created
* @returns false if the file doesn't exist or any other error occured. * @returns false if the file doesn't exist or any other error occured.
*/ */
function read_thumbnail($src) function read_thumbnail($src)
@ -190,10 +190,6 @@ function gen_dstfile($src, $maxsize)
*/ */
function get_scaled_image_size($w, $h, $maxw, $maxh) function get_scaled_image_size($w, $h, $maxw, $maxh)
{ {
//Set the output width to zero
$wout = 0.0;
$hout = 0.0;
//Scale will contain the factor by which the image has to be scaled down //Scale will contain the factor by which the image has to be scaled down
$scale = 1.0; $scale = 1.0;
@ -344,6 +340,7 @@ function gdVersion($user_ver = 0)
// Use the gd_info() function if possible. // Use the gd_info() function if possible.
if (function_exists('gd_info')) { if (function_exists('gd_info')) {
$ver_info = gd_info(); $ver_info = gd_info();
$match = null;
preg_match('/\d/', $ver_info['GD Version'], $match); preg_match('/\d/', $ver_info['GD Version'], $match);
$gd_ver = $match[0]; $gd_ver = $match[0];
return $match[0]; return $match[0];
@ -362,10 +359,7 @@ function gdVersion($user_ver = 0)
// ...otherwise use phpinfo(). // ...otherwise use phpinfo().
ob_start(); ob_start();
phpinfo(8); phpinfo(8);
$info = ob_get_contents(); $info = stristr(ob_get_clean(), 'gd version');
ob_end_clean(); if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0];
$info = stristr($info, 'gd version');
preg_match('/\d/', $info, $match);
$gd_ver = $match[0];
return $match[0]; return $match[0];
} }

View File

@ -29,7 +29,7 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
/** /**
* Set imagemap, called from /phpgwapi/images.php * Set imagemap, called from /phpgwapi/images.php
* *
* @param array/object _images * @param {array|object} _images
*/ */
set_images: function (_images) set_images: function (_images)
{ {
@ -39,8 +39,8 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
/** /**
* Get image URL for a given image-name and application * Get image URL for a given image-name and application
* *
* @param string _name image-name without extension * @param {string} _name image-name without extension
* @param string _app application name, default current app of window * @param {string} _app application name, default current app of window
* @return string with URL of image * @return string with URL of image
*/ */
image: function (_name, _app) image: function (_name, _app)
@ -84,8 +84,8 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
return this.webserverUrl+images['phpgwapi'][_name]; return this.webserverUrl+images['phpgwapi'][_name];
} }
// if no match, check if it might contain an extension // if no match, check if it might contain an extension
var matches = []; var matches = _name.match(/\.(png|gif|jpg)$/i);
if (matches = _name.match(/\.(png|gif|jpg)$/i)) if (matches)
{ {
return this.image(_name.replace(/.(png|gif|jpg)$/i,''), _app); return this.image(_name.replace(/.(png|gif|jpg)$/i,''), _app);
} }
@ -97,9 +97,9 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
/** /**
* Get image url for a given mime-type and option file * Get image url for a given mime-type and option file
* *
* @param _mime * @param {string} _mime
* @param _path vfs path to generate thumbnails for images * @param {string} _path vfs path to generate thumbnails for images
* @param _size defaults to 16 (only supported size currently) * @param {number} _size defaults to 16 (only supported size currently)
* @returns url of image * @returns url of image
*/ */
mime_icon: function(_mime, _path, _size) mime_icon: function(_mime, _path, _size)
@ -109,15 +109,15 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
if (_mime == 'httpd/unix-directory') _mime = 'directory'; if (_mime == 'httpd/unix-directory') _mime = 'directory';
var type = _mime.toLowerCase().split('/'); var type = _mime.toLowerCase().split('/');
var image; var image = type[0] == 'egw' ? this.image('navbar',type[1]) : undefined;
if (type[0] == 'egw' && (image = this.image('navbar',type[1]))) if (image)
{ {
} }
else if (typeof _path == 'string' && type[0] == 'image' && type[1].match(/^(png|jpe?g|gif|bmp)$/)) else if (typeof _path == 'string' && type[0] == 'image' && type[1].match(/^(png|jpe?g|gif|bmp)$/))
{ {
var thsize = this.config('link_list_thumbnail') || 32; var thsize = this.config('link_list_thumbnail') || 64;
image = this.link('/etemplate/thumbnail.php',{ 'path': _path, 'thsize': thsize}); image = this.link('/etemplate/thumbnail.php',{ 'path': _path, 'thsize': thsize});
} }
else else
@ -155,6 +155,6 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
} }
return icon; return icon;
} }
} };
}); });