From 8caca5580cc28dc99d56ff16441eaa138bc3395b Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 8 Apr 2015 14:32:13 +0000 Subject: [PATCH] Some Fixes for images view: -Fix images in listview, clicking on icons does not show the icons in expose view -Fix images always stored as thumbnail and opening them in expose view does not open them in original size -Clicking on thumbnail in details tab, will open the image in a popup with its original size --- resources/inc/class.resources_bo.inc.php | 42 +++++++++++++----------- resources/inc/class.resources_ui.inc.php | 3 +- resources/templates/default/edit.xet | 2 +- resources/templates/default/show.xet | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index f0af53e732..fe3544a601 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -251,7 +251,17 @@ class resources_bo } else { - $rows[$num]['picture_thumb'] = $this->get_picture($resource, true); + $rows[$num]['picture_thumb'] = $this->get_picture($resource, false); + if ($rows[$num]['picture_src'] == 'own_src') + { + // VFS picture fullsize + $rows[$num]['picture_original'] = 'webdav.php/apps/resources/'.$rows[$num]['res_id'].'/.picture.jpg'; + } + else + { + // cat or generic icon fullsize + $rows[$num]['picture_original'] = $this->get_picture($resource, true); + } } $rows[$num]['admin'] = $this->acl->get_cat_admin($resource['cat_id']); } @@ -751,7 +761,7 @@ class resources_bo } /** - * resizes and saves an pictures in vfs + * saves a pictures in vfs * * Cornelius Weiss * @param array $file array with key => value @@ -777,23 +787,8 @@ class resources_bo return lang('Picture type is not supported, sorry!'); } - $src_img_size = getimagesize($file['tmp_name']); - $dst_img_size = array( 0 => 320, 1 => 240); - $tmp_name = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'resources-picture'); - if($src_img_size[0] > $dst_img_size[0] || $src_img_size[1] > $dst_img_size[1]) - { - $f = $dst_img_size[0] / $src_img_size[0]; - $f = $dst_img_size[1] / $src_img_size[1] < $f ? $dst_img_size[1] / $src_img_size[1] : $f; - $dst_img = imagecreatetruecolor($src_img_size[0] * $f, $src_img_size[1] * $f); - imagecopyresized($dst_img,$src_img,0,0,0,0,$src_img_size[0] * $f,$src_img_size[1] * $f,$src_img_size[0],$src_img_size[1]); - imagejpeg($dst_img,$tmp_name); - imagedestroy($dst_img); - } - else - { - imagejpeg($src_img,$tmp_name); - } + imagejpeg($src_img,$tmp_name); imagedestroy($src_img); egw_link::attach_file('resources',$resouce_id,array( @@ -822,6 +817,13 @@ class resources_bo { $picture = egw::link(egw_vfs::download_url($picture)); } + else + { + $picture = egw::link('/etemplate/thumbnail.php', array( + 'path' => $picture, + 'thheight' => 128, + )); + } break; case 'cat_src': @@ -829,14 +831,14 @@ class resources_bo $picture = unserialize($picture['data']); if($picture['icon']) { - $picture = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$picture['icon']; + $picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$picture['icon']:'/phpgwapi/images/'.$picture['icon']; break; } // fall through case 'gen_src': default : $src = $resource['picture_src']; - $picture = $GLOBALS['egw_info']['server']['webserver_url'].$this->resource_icons; + $picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].$this->resource_icons:$this->resource_icons; $picture .= strpos($src,'.') !== false ? $src : 'generic.png'; } return $picture; diff --git a/resources/inc/class.resources_ui.inc.php b/resources/inc/class.resources_ui.inc.php index df0659c878..18d6190ae8 100755 --- a/resources/inc/class.resources_ui.inc.php +++ b/resources/inc/class.resources_ui.inc.php @@ -505,7 +505,8 @@ class resources_ui if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // some presetes - $content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true); + $content['resource_picture'] = $this->bo->get_picture($content['res_id'],false); + $content['picture_original'] = $this->bo->get_picture($content['res_id'],true); $content['quantity'] = $content['quantity'] ? $content['quantity'] : 1; $content['useable'] = $content['useable'] ? $content['useable'] : 1; $content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of; diff --git a/resources/templates/default/edit.xet b/resources/templates/default/edit.xet index 60a32a90cb..e989ff5e67 100644 --- a/resources/templates/default/edit.xet +++ b/resources/templates/default/edit.xet @@ -68,7 +68,7 @@ - + diff --git a/resources/templates/default/show.xet b/resources/templates/default/show.xet index cf6ebb9c24..24a7ea857e 100644 --- a/resources/templates/default/show.xet +++ b/resources/templates/default/show.xet @@ -39,7 +39,7 @@ - +