mirror of
https://github.com/processwire/processwire.git
synced 2025-08-10 16:54:44 +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:
@@ -980,9 +980,10 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
|
|||||||
if(!$width) throw new WireException("Width not specified");
|
if(!$width) throw new WireException("Width not specified");
|
||||||
|
|
||||||
$rebuildVariations = preg_match('/-cropx\d+y\d+/', $image->name);
|
$rebuildVariations = preg_match('/-cropx\d+y\d+/', $image->name);
|
||||||
|
$useResize = ((int) $this->wire('input')->post('use_resize')) == 1;
|
||||||
|
|
||||||
// image2 = resized version
|
// image2 = resized version
|
||||||
if(((int) $this->wire('input')->post('use_resize')) == 1) {
|
if($useResize) {
|
||||||
$image2 = $image->width($width);
|
$image2 = $image->width($width);
|
||||||
if(!$image2 || !$image2->width) throw new WireException('Unable to complete resize');
|
if(!$image2 || !$image2->width) throw new WireException('Unable to complete resize');
|
||||||
} else {
|
} else {
|
||||||
@@ -1059,7 +1060,11 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
|
|||||||
$pathname = $path . $basename;
|
$pathname = $path . $basename;
|
||||||
} while(is_file($pathname));
|
} 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);
|
$pageimages->add($pathname);
|
||||||
$pageimage = $pageimages->last();
|
$pageimage = $pageimages->last();
|
||||||
$pageimage->isTemp(true);
|
$pageimage->isTemp(true);
|
||||||
|
Reference in New Issue
Block a user