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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user