Craft\Imager_ImageModel::__construct PHP Method

__construct() public method

Constructor
public __construct ( null $imagePath = null, null $imageUrl = null, $paths = null, $transform = null )
$imagePath null
$imageUrl null
    public function __construct($imagePath = null, $imageUrl = null, $paths = null, $transform = null)
    {
        if ($imagePath != 'null') {
            $this['path'] = $imagePath;
            $this['extension'] = IOHelper::getExtension($imagePath);
            $this['mimeType'] = IOHelper::getMimeType($imagePath);
            $this['size'] = IOHelper::getFileSize($imagePath);
            $imageInfo = @getimagesize($imagePath);
            if (is_array($imageInfo) && $imageInfo[0] !== '' && $imageInfo[1] !== '') {
                $this['width'] = $imageInfo[0];
                $this['height'] = $imageInfo[1];
            } else {
                // Couldn't get size. Calculate size based on source image and transform.
                $sourceImageInfo = @getimagesize($paths->sourcePath . $paths->sourceFilename);
                $sourceSize = new \Imagine\Image\Box($sourceImageInfo[0], $sourceImageInfo[1]);
                $targetCrop = craft()->imager->getCropSize($sourceSize, $transform);
                $this['width'] = $targetCrop->getWidth();
                $this['height'] = $targetCrop->getHeight();
            }
        }
        if ($imageUrl != 'null') {
            $this['url'] = $imageUrl;
        }
    }