Skip to content

Commit

Permalink
* Workaround for masterexploder/PHPThumb#131 (sizeof on null)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaselkowski committed Sep 8, 2017
1 parent 141000a commit 0a28fc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/Helpers/ImageThumb.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Maslosoft\Mangan\Helpers;

use PHPThumb\GD;

/**
* ImageThumb
*
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
class ImageThumb extends GD
{
protected $options = [];
}
5 changes: 3 additions & 2 deletions src/Model/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Maslosoft\Mangan\Model;

use Exception;
use Maslosoft\Mangan\Helpers\ImageThumb;
use MongoGridFSFile;
use PHPThumb\GD;

Expand Down Expand Up @@ -68,7 +69,7 @@ public function get(ImageParams $params = null)
$result->write($fileName);


$image = new GD($fileName);
$image = new ImageThumb($fileName);
if ($params->adaptive)
{
$image->adaptiveResize($params->width, $params->height)->save($fileName);
Expand Down Expand Up @@ -98,7 +99,7 @@ protected function _set($tempName, $fileName, $params = [])
{
if ($this->isImage($fileName))
{
$thumb = new GD($tempName);
$thumb = new ImageThumb($tempName);
$dimensions = (object) $thumb->getCurrentDimensions();
$this->width = $dimensions->width;
$this->height = $dimensions->height;
Expand Down

0 comments on commit 0a28fc2

Please sign in to comment.