1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 08:17:12 +02:00

Fix issue #12 where image was broken when repurposing the image crop function "save as a copy" as an image duplicate function.

This commit is contained in:
Ryan Cramer
2016-09-30 08:49:30 -04:00
parent 5922c90048
commit 1cbd3fa9a4

View File

@@ -980,9 +980,10 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
if(!$width) throw new WireException("Width not specified");
$rebuildVariations = preg_match('/-cropx\d+y\d+/', $image->name);
$useResize = ((int) $this->wire('input')->post('use_resize')) == 1;
// image2 = resized version
if(((int) $this->wire('input')->post('use_resize')) == 1) {
if($useResize) {
$image2 = $image->width($width);
if(!$image2 || !$image2->width) throw new WireException('Unable to complete resize');
} else {
@@ -1059,7 +1060,11 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
$pathname = $path . $basename;
} while(is_file($pathname));
rename($image2->filename(), $pathname);
if(!$useResize && !$rebuildVariations) {
$this->wire('files')->copy($image2->filename(), $pathname);
} else {
rename($image2->filename(), $pathname);
}
$pageimages->add($pathname);
$pageimage = $pageimages->last();
$pageimage->isTemp(true);