infoweb\cms\models\Image::getUrl PHP Метод

getUrl() публичный Метод

public getUrl ( $size = false, $crop = true, $fitImageInCanvas = false )
    public function getUrl($size = false, $crop = true, $fitImageInCanvas = false)
    {
        // Check if the image exists or return a placeholder
        if (!file_exists(Yii::getAlias('@uploadsBasePath/img/') . $this->filePath)) {
            $img = new PlaceHolder();
            return $img->getUrl($size);
        }
        $urlSize = $size ? '_' . $size : '';
        $base = $this->getModule()->getCachePath();
        $sub = $this->getSubDur();
        $origin = $this->getPathToOrigin();
        $filePath = $base . '/' . $sub . '/' . $this->urlAlias . $urlSize . '.' . pathinfo($origin, PATHINFO_EXTENSION);
        if (!file_exists($filePath)) {
            $this->createVersion($origin, $size, $crop, $fitImageInCanvas);
            if (!file_exists($filePath)) {
                throw new \Exception(Yii::t('app', 'The image does not exist'));
            }
        }
        $httpPath = \Yii::getAlias('@uploadsBaseUrl') . '/img/cache/' . $sub . '/' . $this->urlAlias . $urlSize . '.' . pathinfo($origin, PATHINFO_EXTENSION);
        return $httpPath;
    }