From 692abe16504d09336266ae03c749da4046962b00 Mon Sep 17 00:00:00 2001 From: flop25 Date: Sat, 26 Mar 2011 14:29:27 +0000 Subject: feature:2230 the size of the squared thumbnails depend of the sizes of all the thumbnails : the clipping is an average of the clipping of each of the thumbnails git-svn-id: http://piwigo.org/svn/trunk@9864 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/element_set_ranks.php | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'admin/element_set_ranks.php') diff --git a/admin/element_set_ranks.php b/admin/element_set_ranks.php index edb802b58..4c16b3cba 100644 --- a/admin/element_set_ranks.php +++ b/admin/element_set_ranks.php @@ -209,31 +209,44 @@ $result = pwg_query($query); // template thumbnail initialization $current_rank = 1; - +$thumbnail_info=array(); +$clipping=array(); while ($row = pwg_db_fetch_assoc($result)) { $src = get_thumbnail_url($row); + + $thumbnail_size = getimagesize($src); + $thumbnail_info[] = array( + 'width' => $thumbnail_size[0], + 'height' => $thumbnail_size[1], + 'id' => $row['id'], + 'tn_src' => $src, + 'rank' => $current_rank * 10, + ); + $clipping[]= min($thumbnail_size[0]*0.75,$thumbnail_size[1]*0.75); - list($thumbnail_width, $thumbnail_height) = getimagesize($src); - $thumbnail_x_center = $thumbnail_width/2; - $thumbnail_y_center = $thumbnail_height/2; - + $current_rank++; +} +$clipping=array_sum($clipping)/count($clipping); +foreach ($thumbnail_info as $thumbnails_info) +{ + $thumbnail_x_center = $thumbnails_info['width']/2; + $thumbnail_y_center = $thumbnails_info['height']/2; $template->append( 'thumbnails', array( - 'ID' => $row['id'], - 'TN_SRC' => $src, - 'RANK' => $current_rank * 10, - 'CLIP_TOP' => round($thumbnail_y_center - 96/2), - 'CLIP_RIGHT' => round($thumbnail_x_center + 96/2), - 'CLIP_BOTTOM' => round($thumbnail_y_center + 96/2), - 'CLIP_LEFT' => round($thumbnail_x_center - 96/2) + 'ID' => $thumbnails_info['id'], + 'TN_SRC' => $thumbnails_info['tn_src'], + 'RANK' => $thumbnails_info['rank'], + 'CLIPING' => round($clipping), + 'CLIPING_li' => round($clipping+8), + 'CLIP_TOP' => round($thumbnail_y_center - $clipping/2), + 'CLIP_RIGHT' => round($thumbnail_x_center + $clipping/2), + 'CLIP_BOTTOM' => round($thumbnail_y_center + $clipping/2), + 'CLIP_LEFT' => round($thumbnail_x_center - $clipping/2) ) ); - - $current_rank++; } - // image order management $sort_fields = array( '' => '', -- cgit v1.2.3