Skip to content

Commit

Permalink
feature 2541 multisize
Browse files Browse the repository at this point in the history
- core implementation + usage on most public/admin pages
- still to do: sync process, upload, gui/persistence for size parameters, migration script, center of interest ...

git-svn-id: http://piwigo.org/svn/trunk@12796 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Dec 27, 2011
1 parent e77e68b commit 753f58d
Show file tree
Hide file tree
Showing 27 changed files with 1,113 additions and 208 deletions.
4 changes: 2 additions & 2 deletions admin/batch_manager_global.php
Expand Up @@ -711,7 +711,7 @@


$query = '
SELECT id,path,tn_ext,file,filesize,level,name
SELECT id,path,representative_ext,file,filesize,level,name
FROM '.IMAGES_TABLE;

if ($is_category)
Expand Down Expand Up @@ -747,7 +747,7 @@
while ($row = pwg_db_fetch_assoc($result))
{
$nb_thumbs_page++;
$src = get_thumbnail_url($row);
$src = DerivativeImage::thumb_url($row);

$title = $row['name'];
if (empty($title))
Expand Down
4 changes: 2 additions & 2 deletions admin/batch_manager_unit.php
Expand Up @@ -201,7 +201,7 @@


$query = '
SELECT id,path,tn_ext,name,date_creation,comment,author,level,file
SELECT id,path,representative_ext,name,date_creation,comment,author,level,file
FROM '.IMAGES_TABLE;

if ($is_category)
Expand Down Expand Up @@ -237,7 +237,7 @@
{
array_push($element_ids, $row['id']);

$src = get_thumbnail_url($row);
$src = DerivativeImage::thumb_url($row);

// creation date
if (!empty($row['date_creation']))
Expand Down
8 changes: 4 additions & 4 deletions admin/cat_modify.php
Expand Up @@ -301,12 +301,12 @@
if (!empty($category['representative_picture_id']))
{
$query = '
SELECT id,tn_ext,path
SELECT id,representative_ext,path
FROM '.IMAGES_TABLE.'
WHERE id = '.$category['representative_picture_id'].'
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$src = get_thumbnail_url($row);
$src = DerivativeImage::thumb_url($row);
$url = get_root_url().'admin.php?page=picture_modify';
$url.= '&image_id='.$category['representative_picture_id'];

Expand Down Expand Up @@ -387,7 +387,7 @@
if (!empty($category['representative_picture_id']))
{
$query = '
SELECT id, file, path, tn_ext
SELECT id, file, path, representative_ext
FROM '.IMAGES_TABLE.'
WHERE id = '.$category['representative_picture_id'].'
;';
Expand All @@ -403,7 +403,7 @@
'image_file' => $element['file'],
'category' => $category
))
.'" class="thumblnk"><img src="'.get_thumbnail_url($element).'"></a>';
.'" class="thumblnk"><img src="'.DerivativeImage::thumb_url($element).'"></a>';
}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/comments.php
Expand Up @@ -99,7 +99,7 @@

$query = '
SELECT c.id, c.image_id, c.date, c.author, '.
$conf['user_fields']['username'].' AS username, c.content, i.path, i.tn_ext
$conf['user_fields']['username'].' AS username, c.content, i.path, i.representative_ext
FROM '.COMMENTS_TABLE.' AS c
INNER JOIN '.IMAGES_TABLE.' AS i
ON i.id = c.image_id
Expand All @@ -111,7 +111,7 @@
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
$thumb = get_thumbnail_url(
$thumb = DerivativeImage::thumb_url(
array(
'id'=>$row['image_id'],
'path'=>$row['path'],
Expand Down
10 changes: 6 additions & 4 deletions admin/element_set_ranks.php
Expand Up @@ -199,7 +199,8 @@ function save_images_order($category_id, $images)
id,
file,
path,
tn_ext,
representative_ext,
width, height,
name,
rank
FROM '.IMAGES_TABLE.'
Expand All @@ -214,11 +215,12 @@ function save_images_order($category_id, $images)
$current_rank = 1;
$thumbnail_info=array();
$clipping=array();
$derivativeParams = ImageStdParams::get_by_type(IMG_SQUARE);
while ($row = pwg_db_fetch_assoc($result))
{
$src = get_thumbnail_url($row);
$derivative = new DerivativeImage($derivativeParams, new SrcImage($row));

$thumbnail_size = getimagesize($src);
$thumbnail_size = $derivative->get_size();
if ( !empty( $row['name'] ) )
{
$thumbnail_name = $row['name'];
Expand All @@ -233,7 +235,7 @@ function save_images_order($category_id, $images)
'width' => $thumbnail_size[0],
'height' => $thumbnail_size[1],
'id' => $row['id'],
'tn_src' => $src,
'tn_src' => $derivative->get_url(),
'rank' => $current_rank * 10,
);
if ($thumbnail_size[0]<=128 and $thumbnail_size[1]<=128)
Expand Down
12 changes: 6 additions & 6 deletions admin/history.php
Expand Up @@ -303,7 +303,7 @@
high_filesize,
file,
path,
tn_ext
representative_ext
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', array_keys($image_ids)).')
;';
Expand All @@ -313,7 +313,7 @@
$high_filesize_of_image = array();
$file_of_image = array();
$path_of_image = array();
$tn_ext_of_image = array();
$representative_ext_of_image = array();

$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
Expand All @@ -332,7 +332,7 @@

$file_of_image[ $row['id'] ] = $row['file'];
$path_of_image[ $row['id'] ] = $row['path'];
$tn_ext_of_image[ $row['id'] ] = $row['tn_ext'];
$representative_ext_of_image[ $row['id'] ] = $row['representative_ext'];
}

// echo '<pre>'; print_r($high_filesize_of_image); echo '</pre>';
Expand Down Expand Up @@ -454,7 +454,7 @@
'id' => $line['image_id'],
'file' => $file_of_image[$line['image_id']],
'path' => $path_of_image[$line['image_id']],
'tn_ext' => $tn_ext_of_image[$line['image_id']],
'representative_ext' => $representative_ext_of_image[$line['image_id']],
);
$thumbnail_display = $page['search']['fields']['display_thumbnail'];
}
Expand Down Expand Up @@ -487,7 +487,7 @@
{
$image_string =
'<a class="thumbnail" href="'.$picture_url.'">'
.'<span><img src="'.get_thumbnail_url($element)
.'<span><img src="'.DerivativeImage::thumb_url($element)
.'" alt="'.$image_title.'" title="'.$image_title.'">'
.'</span></a>';
break;
Expand All @@ -496,7 +496,7 @@
{
$image_string =
'<a class="over" href="'.$picture_url.'">'
.'<span><img src="'.get_thumbnail_url($element)
.'<span><img src="'.DerivativeImage::thumb_url($element)
.'" alt="'.$image_title.'" title="'.$image_title.'">'
.'</span>'.$image_title.'</a>';
break;
Expand Down
2 changes: 1 addition & 1 deletion admin/picture_modify.php
Expand Up @@ -282,7 +282,7 @@

'PATH'=>$row['path'],

'TN_SRC' => get_thumbnail_url($row),
'TN_SRC' => DerivativeImage::thumb_url($row),

'NAME' =>
isset($_POST['name']) ?
Expand Down
4 changes: 2 additions & 2 deletions admin/rating.php
Expand Up @@ -184,7 +184,7 @@
GROUP BY i.id,
i.path,
i.file,
i.tn_ext,
i.representative_ext,
i.rating_score,
r.element_id
ORDER BY ' . $available_order_by[$order_by_index][1] .'
Expand All @@ -201,7 +201,7 @@
$template->assign( 'images', array() );
foreach ($images as $image)
{
$thumbnail_src = get_thumbnail_url($image);
$thumbnail_src = DerivativeImage::thumb_url($image);

$image_url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
'&amp;image_id='.$image['id'];
Expand Down
6 changes: 3 additions & 3 deletions admin/rating_user.php
Expand Up @@ -101,14 +101,14 @@
$image_urls = array();
if (count($image_ids) > 0 )
{
$query = 'SELECT id, name, file, path, tn_ext
$query = 'SELECT id, name, file, path, representative_ext
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', array_keys($image_ids)).')';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
$image_urls[ $row['id'] ] = array(
'tn' => get_thumbnail_url($row),
'tn' => DerivativeImage::thumb_url($row),
'page' => make_picture_url( array('image_id'=>$row['id'], 'image_file'=>$row['file']) ),
);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ function consensus_dev_compare($a, $b)
'available_rates' => $conf['rate_items'],
'ratings' => $by_user_ratings,
'image_urls' => $image_urls,
'TN_WIDTH' => 20+2*$conf['upload_form_thumb_maxwidth'],
'TN_WIDTH' => 28+2*ImageStdParams::get_by_type(IMG_THUMB)->sizing->ideal_size[0],
) );
$template->set_filename('rating', 'rating_user.tpl');
$template->assign_var_from_handle('ADMIN_CONTENT', 'rating');
Expand Down
4 changes: 2 additions & 2 deletions admin/themes/default/template/rating_user.tpl
Expand Up @@ -59,7 +59,7 @@ function del(elt,uid,aid)
<td>{if !empty($rates)}
{capture assign=rate_over}{foreach from=$rates item=rate_arr}<img src="{$image_urls[$rate_arr.id].tn}" alt="thumb-{$rate_arr.id}" title="{$rate_arr.date}"></img>
{/foreach}{/capture}
<a class="cluetip" title="{$rate_over|@htmlspecialchars}">{$rates|@count}</a>
<a class="cluetip" title="|{$rate_over|@htmlspecialchars}">{$rates|@count}</a>
{/if}</td>
{/foreach}
<td><a onclick="return del(this,{$rating.uid},'{$rating.aid}');"><img src="{$themeconf.admin_icon_dir}/delete.png" alt="[{'Delete'|@translate}]"></a></td>
Expand All @@ -71,7 +71,7 @@ function del(elt,uid,aid)
{footer_script require='jquery.cluetip'}
jQuery(document).ready(function(){ldelim}
jQuery('.cluetip').cluetip({ldelim}
width: {$TN_WIDTH}, splitTitle: '|'
width: {$TN_WIDTH}, showTitle:false, splitTitle: '|'
});
})
{/footer_script}
4 changes: 2 additions & 2 deletions comments.php
Expand Up @@ -408,7 +408,7 @@
// retrieving element informations
$elements = array();
$query = '
SELECT id, name, file, path, tn_ext
SELECT id, name, file, path, representative_ext
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', $element_ids).')
;';
Expand Down Expand Up @@ -450,7 +450,7 @@
}

// source of the thumbnail picture
$thumbnail_src = get_thumbnail_url( $elements[$comment['image_id']] );
$thumbnail_src = DerivativeImage::thumb_url( $elements[$comment['image_id']] );

// link to the full size picture
$url = make_picture_url(
Expand Down

0 comments on commit 753f58d

Please sign in to comment.