Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
#10 - img small refact
Browse files Browse the repository at this point in the history
  • Loading branch information
nizsheanez committed Aug 25, 2012
1 parent e689c44 commit dd8eef7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions protected/components/ImageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@ class ImageHolder //Класс Image занять под расширение
private $_size;
private $_crop;

public function crop()
{
$this->_crop = true;
return $this;
}

public function __construct($dir, $file, array $size, $crop = false)

public function setSize(array $size)
{
$this->_size = $size;
return $this;
}

public function load($dir, $file)
{
$this->_dir = $dir;
$this->_file = $file;
$this->_size = $size;
$this->_crop = $crop;
return $this;
}

Expand Down Expand Up @@ -76,7 +86,12 @@ public static function placeholder(array $size, $text = null)

public static function thumb($dir, $file, array $size, $crop = false)
{
return new ImageHolder($dir, $file, $size, $crop);
$img = new ImageHolder();
$img->load($dir, $file)->setSize($size);
if ($crop) {
$img->crop();
}
return $img;
}


Expand Down

0 comments on commit dd8eef7

Please sign in to comment.