|
|
|
|
|
|
|
|
public $default_width = 500; |
|
|
public $default_width = 500; |
|
|
public $format; |
|
|
public $format; |
|
|
public $quality; |
|
|
public $quality; |
|
|
|
|
|
private $usecache = true; |
|
|
|
|
|
|
|
|
function __construct($path) { |
|
|
|
|
|
|
|
|
function __construct($path,$format=false) { |
|
|
$f3 = \Base::instance(); |
|
|
$f3 = \Base::instance(); |
|
|
$this->original = $path; |
|
|
$this->original = $path; |
|
|
$this->format = $f3->get('cachedImageFormat') ? : 'jpeg'; |
|
|
$this->format = $f3->get('cachedImageFormat') ? : 'jpeg'; |
|
|
$this->quality = $f3->get('cachedImageQuality') ? : false; |
|
|
$this->quality = $f3->get('cachedImageQuality') ? : false; |
|
|
|
|
|
|
|
|
|
|
|
if (is_string($format)) { |
|
|
|
|
|
$format = strtolower($format); |
|
|
|
|
|
if (in_array($format, ['png','jpg','jpeg'])) { |
|
|
|
|
|
$this->format = $format; |
|
|
|
|
|
} elseif ($format == "nocache") { |
|
|
|
|
|
$this->usecache = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ($this->quality === false) { |
|
|
if ($this->quality === false) { |
|
|
switch($this->format) { |
|
|
switch($this->format) { |
|
|
case 'png': |
|
|
case 'png': |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function get_src($inwidth = 500) { |
|
|
|
|
|
|
|
|
function get_src($inwidth = false) { |
|
|
$f3 = \Base::instance(); |
|
|
$f3 = \Base::instance(); |
|
|
if($this->is_image($this->original) && TRUE) { |
|
|
|
|
|
|
|
|
if($this->is_image($this->original) && $this->usecache) { |
|
|
$info = pathinfo($this->original); |
|
|
$info = pathinfo($this->original); |
|
|
$fn = basename($this->original,'.'.$info['extension']); |
|
|
$fn = basename($this->original,'.'.$info['extension']); |
|
|
$width = $inwidth ? $inwidth : $this->default_width; |
|
|
$width = $inwidth ? $inwidth : $this->default_width; |