mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 09:14:58 +02:00
Fix issue processwire/processwire-issues#1560
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Helper class for Pageimage that handles variation collection methods
|
* Helper class for Pageimage that handles variation collection methods
|
||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
* @since 3.0.137
|
* @since 3.0.137
|
||||||
@@ -461,6 +461,8 @@ class PageimageVariations extends Wire implements \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function rebuild($mode = 0, array $suffix = array(), array $options = array()) {
|
public function rebuild($mode = 0, array $suffix = array(), array $options = array()) {
|
||||||
|
|
||||||
|
$files = $this->wire()->files;
|
||||||
|
|
||||||
$skipped = array();
|
$skipped = array();
|
||||||
$rebuilt = array();
|
$rebuilt = array();
|
||||||
$errors = array();
|
$errors = array();
|
||||||
@@ -528,9 +530,9 @@ class PageimageVariations extends Wire implements \IteratorAggregate, \Countable
|
|||||||
$o['suffix'] = $info['suffix'];
|
$o['suffix'] = $info['suffix'];
|
||||||
|
|
||||||
if(is_file($info['path'])) {
|
if(is_file($info['path'])) {
|
||||||
$this->wire('files')->unlink($info['path'], true);
|
$files->unlink($info['path'], true);
|
||||||
if(!empty($info['webpPath']) && is_file($info['webpPath'])) {
|
if(!empty($info['webpPath']) && $files->exists($info['webpPath'])) {
|
||||||
$this->wire('files')->unlink($info['webpPath'], true);
|
$files->unlink($info['webpPath'], true);
|
||||||
$hadWebp = true;
|
$hadWebp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -538,11 +540,11 @@ class PageimageVariations extends Wire implements \IteratorAggregate, \Countable
|
|||||||
/*
|
/*
|
||||||
if(!$info['width'] && $info['actualWidth']) {
|
if(!$info['width'] && $info['actualWidth']) {
|
||||||
$info['width'] = $info['actualWidth'];
|
$info['width'] = $info['actualWidth'];
|
||||||
$options['nameWidth'] = 0;
|
$o['nameWidth'] = 0;
|
||||||
}
|
}
|
||||||
if(!$info['height'] && $info['actualHeight']) {
|
if(!$info['height'] && $info['actualHeight']) {
|
||||||
$info['height'] = $info['actualHeight'];
|
$info['height'] = $info['actualHeight'];
|
||||||
$options['nameHeight'] = 0;
|
$o['nameHeight'] = 0;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -550,25 +552,25 @@ class PageimageVariations extends Wire implements \IteratorAggregate, \Countable
|
|||||||
// dimensional cropping info contained in filename
|
// dimensional cropping info contained in filename
|
||||||
$cropX = (int) $matches[1];
|
$cropX = (int) $matches[1];
|
||||||
$cropY = (int) $matches[2];
|
$cropY = (int) $matches[2];
|
||||||
$variation = $this->pageimage->crop($cropX, $cropY, $info['width'], $info['height'], $options);
|
$variation = $this->pageimage->crop($cropX, $cropY, $info['width'], $info['height'], $o);
|
||||||
|
|
||||||
} else if($info['crop']) {
|
} else if($info['crop']) {
|
||||||
// direct cropping info contained in filename
|
// direct cropping info contained in filename
|
||||||
$options['cropping'] = $info['crop'];
|
$options['cropping'] = $info['crop'];
|
||||||
$variation = $this->pageimage->size($info['width'], $info['height'], $options);
|
$variation = $this->pageimage->size($info['width'], $info['height'], $o);
|
||||||
|
|
||||||
} else if($this->pageimage->hasFocus) {
|
} else if($this->pageimage->hasFocus) {
|
||||||
// crop to focus area, which the size() method will determine on its own
|
// crop to focus area, which the size() method will determine on its own
|
||||||
$variation = $this->pageimage->size($info['width'], $info['height'], $options);
|
$variation = $this->pageimage->size($info['width'], $info['height'], $o);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no crop, no focus, just resize
|
// no crop, no focus, just resize
|
||||||
$variation = $this->pageimage->size($info['width'], $info['height'], $options);
|
$variation = $this->pageimage->size($info['width'], $info['height'], $o);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($variation) {
|
if($variation) {
|
||||||
if($variation->name != $name) {
|
if($variation->name != $name) {
|
||||||
rename($variation->filename(), $info['path']);
|
$files->rename($variation->filename(), $info['path']);
|
||||||
$variation->data('basename', $name);
|
$variation->data('basename', $name);
|
||||||
}
|
}
|
||||||
$rebuilt[] = $name;
|
$rebuilt[] = $name;
|
||||||
|
Reference in New Issue
Block a user