diff --git a/docs/NEWS b/docs/NEWS index 0ddbf749..46900512 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -1,6 +1,8 @@ Version 2.1 () ------------------------------------------------------------------------ + * Optimize scaleImage returns + * Fixed media item rename handler (#370) * Fixed and enhanced multiple media redirects and path / name diff --git a/include/admin/images.inc.php b/include/admin/images.inc.php index 553b0870..bbe49ec0 100644 --- a/include/admin/images.inc.php +++ b/include/admin/images.inc.php @@ -675,15 +675,25 @@ switch ($serendipity['GET']['adminAction']) { return; } - $data['case_scale'] = true; - $data['print_SCALING_IMAGE'] = sprintf( - SCALING_IMAGE, - $file['path'] . $file['name'] .'.'. $file['extension'], - (int)$serendipity['GET']['width'], - (int)$serendipity['GET']['height'] - ); - $data['extraParems'] = serendipity_generateImageSelectorParems(); - $data['print_serendipity_scaleImg'] = serendipity_scaleImg($serendipity['GET']['fid'], $serendipity['GET']['width'], $serendipity['GET']['height']); + $data['case_scale'] = true; // this allows to use the showML fallback too + if ($serendipity['GET']['width'] == $file['dimensions_width'] && $serendipity['GET']['height'] == $file['dimensions_height']) { + $data['messages'] = ' ' . MEDIA_RESIZE_EXISTS . ''; + } else { + $data['print_SCALING_IMAGE'] = sprintf( + SCALING_IMAGE, + $file['path'] . $file['name'] .'.'. $file['extension'], + (int)$serendipity['GET']['width'], + (int)$serendipity['GET']['height'] + ); + $data['extraParems'] = serendipity_generateImageSelectorParems(); + $scaleImg = serendipity_scaleImg($serendipity['GET']['fid'], $serendipity['GET']['width'], $serendipity['GET']['height']); + if (!empty($scaleImg) && is_string($scaleImg)) { + $data['scaleImgError'] = $scaleImg; + } + $data['is_done'] = true; + } + // fall back + $data['showML'] = showMediaLibrary(); break; case 'scaleSelect': diff --git a/lang/addlang.txt b/lang/addlang.txt index 4567658c..0237e45d 100644 --- a/lang/addlang.txt +++ b/lang/addlang.txt @@ -7,3 +7,4 @@ @define('MEDIA_PROPERTIES_DONE', 'Properties of #%d changed.'); @define('DIRECTORY_INFO', 'Directory info helper'); @define('DIRECTORY_INFO_DESC', 'Directories are based to their physical folder directory name. If you want to change or move directories with items, you have two choices. Either create the directory or subdirectory you want, then move the items to the new directory via the MediaLibrary and after all, delete the now emptied old directory here. Or edit the old directory via the edit directory button below and rename it to whatever you like (existing subdir/ +) newname. This will move all directories and items and rename entry path too.'); +@define('MEDIA_RESIZE_EXISTS', 'File dimensions already exist!'); diff --git a/templates/2k11/admin/images.inc.tpl b/templates/2k11/admin/images.inc.tpl index 8c3d99b4..efa6c63c 100644 --- a/templates/2k11/admin/images.inc.tpl +++ b/templates/2k11/admin/images.inc.tpl @@ -237,9 +237,9 @@ {/if} {/if} {if $case_scale} - {if $print_SCALING_IMAGE} {$print_SCALING_IMAGE}{/if} - {if $print_serendipity_scaleImg} {$print_serendipity_scaleImg}{/if} - {$CONST.DONE} + {if isset($print_SCALING_IMAGE)} {$print_SCALING_IMAGE}{/if} + {if isset($scaleImgError)} {$scaleImgError}{/if} + {if isset($is_done)} {$CONST.DONE}{/if} {if $showML}{$showML}{/if} {/if} {if $case_scaleSelect}