From: slothman Date: Wed, 9 Apr 2008 01:57:10 +0000 (+0000) Subject: Correct thumbnail constraints. S9Y now supports width, height, largest, X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3885812999e729e5a85979e8ab19613b4b558afe;p=s9y.git Correct thumbnail constraints. S9Y now supports width, height, largest, and smallest constraints. Backwards compatibility is maintained with the imageselectorplus plugin (the only plugin to use the thumbnail or aspect calculation code). Language files are updated and a new option screen is displayed after choosing "Rebuild Thumbs". --- diff --git a/include/admin/images.inc.php b/include/admin/images.inc.php index fe9e876..791a1f7 100644 --- a/include/admin/images.inc.php +++ b/include/admin/images.inc.php @@ -47,6 +47,33 @@ switch ($serendipity['GET']['adminAction']) { case 'sync': if (!serendipity_checkPermission('adminImagesSync')) { + echo '
' . PERM_DENIED . '
'; + break; + } + + // Make the form to actually do sync with deleting or not + $n = "\n"; + $warning = preg_replace('#\\\n#', '
', WARNING_THIS_BLAHBLAH); + echo '
' . $warning . '
'; + echo '
' . $n; + echo '

' . $n . '

' . $n; + echo ' ' . SYNC_OPTION_LEGEND . '' . $n; + echo ' ' .$n; + echo '
' . $n; + echo ' ' . $n; + echo '
' . $n; + echo ' ' . $n; + echo '
' . $n; + echo '
' . $n . '

' . $n; + echo ' ' . $n; + echo ' ' . ABORT_NOW . '' . $n; + echo '
'; + break; + + case 'doSync': + // I don't know how it could've changed, but let's be safe. + if (!serendipity_checkPermission('adminImagesSync')) { + echo '
' . PERM_DENIED . '
'; break; } @@ -58,7 +85,19 @@ switch ($serendipity['GET']['adminAction']) { echo '

' . SYNCING . '


'; flush(); - $i = serendipity_syncThumbs(); + $deleteThumbs = false; + if (isset($serendipity['POST']['deleteThumbs'])) { + switch ($serendipity['POST']['deleteThumbs']) + { + case 'yes': + $deleteThumbs = true; + break; + case 'check': + $deleteThumbs = 'checksize'; + break; + } + } + $i = serendipity_syncThumbs($deleteThumbs); printf(SYNC_DONE, $i); echo '

' . RESIZING . '


'; diff --git a/include/functions_images.inc.php b/include/functions_images.inc.php index 2841fb8..a8e3150 100644 --- a/include/functions_images.inc.php +++ b/include/functions_images.inc.php @@ -643,15 +643,19 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb } else { if ($serendipity['magick'] !== true) { if (is_array($size)) { + // The caller wants a thumbnail with a specific size $r = serendipity_resize_image_gd($infile, $outfile, $size['width'], $size['height']); } else { - $r = serendipity_resize_image_gd($infile, $outfile, $size); + // The caller wants a thumbnail constrained in the dimension set by config + $calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']); + $r = serendipity_resize_image_gd($infile, $outfile, $calc[0], $calc[1]); } } else { if (is_array($size)) { $r = $size; } else { - $r = array('width' => $size, 'height' => $size); + $calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']); + $r = array('width' => $calc[0], 'height' => $calc[1]); } $newSize = $r['width'] . 'x' . $r['height']; if ($fdim['mime'] == 'application/pdf') { @@ -788,6 +792,7 @@ function serendipity_generateThumbs() { $i=0; $serendipity['imageList'] = serendipity_fetchImagesFromDatabase(0, 0, $total); + $msg_printed = false; foreach ($serendipity['imageList'] AS $k => $file) { $is_image = serendipity_isImage($file); @@ -808,25 +813,37 @@ function serendipity_generateThumbs() { $oldThumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension']; $newThumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . '.' . $serendipity['thumbSuffix'] . '.' . $file['extension']; + $sThumb = $file['path'] . $file['name'] . '.' . $serendipity['thumbSuffix'] . '.' . $file['extension']; $fdim = @getimagesize($ffull); if (!file_exists($oldThumb) && !file_exists($newThumb) && ($fdim[0] > $serendipity['thumbSize'] || $fdim[1] > $serendipity['thumbSize'])) { $returnsize = serendipity_makeThumbnail($file['name'] . '.' . $file['extension'], $file['path']); if ($returnsize !== false ) { - printf(RESIZE_BLAHBLAH, $filename . ': ' . $returnsize[0] . 'x' . $returnsize[1]); + // Only print the resize message the first time + if (!$msg_printed) { + printf(RESIZE_BLAHBLAH, THUMBNAIL_SHORT); + echo "\n" . '