mirror of
https://github.com/getgrav/grav.git
synced 2026-02-28 09:31:32 +01:00
Fixed StaticResizeTrait::resize() bad image height/width attributes if null values are passed to the method
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
* Fixed unimplemented `PageObject::getOriginal()` call [#3098](https://github.com/getgrav/grav/issues/3098)
|
||||
* Fixed `Argument 1 passed to Grav\Common\User\DataUser\User::filterUsername() must be of the type string` [#3101](https://github.com/getgrav/grav/issues/3101)
|
||||
* Fixed broken check if php exif module is enabled in `ImageFile::fixOrientation()`
|
||||
* Fixed `StaticResizeTrait::resize()` bad image height/width attributes if `null` values are passed to the method
|
||||
|
||||
# v1.7.0-rc.19
|
||||
## 12/02/2020
|
||||
|
||||
@@ -24,8 +24,16 @@ trait StaticResizeTrait
|
||||
*/
|
||||
public function resize($width = null, $height = null)
|
||||
{
|
||||
$this->styleAttributes['width'] = $width . 'px';
|
||||
$this->styleAttributes['height'] = $height . 'px';
|
||||
if ($width) {
|
||||
$this->styleAttributes['width'] = $width . 'px';
|
||||
} else {
|
||||
unset($this->styleAttributes['width']);
|
||||
}
|
||||
if ($height) {
|
||||
$this->styleAttributes['height'] = $height . 'px';
|
||||
} else {
|
||||
unset($this->styleAttributes['height']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
namespace Grav\Common\Page\Medium;
|
||||
|
||||
use Grav\Common\Media\Traits\StaticResizeTrait as NewResizeTrait;
|
||||
|
||||
user_error('Grav\Common\Page\Medium\StaticResizeTrait is deprecated since Grav 1.7, use Grav\Common\Media\Traits\StaticResizeTrait instead', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
@@ -18,18 +20,5 @@ user_error('Grav\Common\Page\Medium\StaticResizeTrait is deprecated since Grav 1
|
||||
*/
|
||||
trait StaticResizeTrait
|
||||
{
|
||||
/**
|
||||
* Resize media by setting attributes
|
||||
*
|
||||
* @param int|null $width
|
||||
* @param int|null $height
|
||||
* @return $this
|
||||
*/
|
||||
public function resize($width = null, $height = null)
|
||||
{
|
||||
$this->styleAttributes['width'] = $width . 'px';
|
||||
$this->styleAttributes['height'] = $height . 'px';
|
||||
|
||||
return $this;
|
||||
}
|
||||
use NewResizeTrait;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user