Craft\Imager_ImagePathsModel::_getPathsForUrl PHP Method

_getPathsForUrl() private method

Get paths for an external file (really external, or on an external source type)
private _getPathsForUrl ( $image )
$image
    private function _getPathsForUrl($image)
    {
        $convertedImageStr = StringHelper::asciiString(urldecode($image));
        $urlParts = parse_url($convertedImageStr);
        $pathParts = pathinfo($urlParts['path']);
        $hashRemoteUrl = craft()->imager->getSetting('hashRemoteUrl');
        $hashPath = craft()->imager->getSetting('hashPath');
        if ($hashPath) {
            $targetFolder = '/' . md5($pathParts['dirname']);
        } else {
            $targetFolder = $pathParts['dirname'];
        }
        if ($hashRemoteUrl) {
            if (is_string($hashRemoteUrl) && $hashRemoteUrl == 'host') {
                $parsedDirname = substr(md5($urlParts['host']), 0, 10) . $targetFolder;
            } else {
                $parsedDirname = md5($urlParts['host'] . $pathParts['dirname']);
            }
        } else {
            $parsedDirname = str_replace('.', '_', $urlParts['host']) . $targetFolder;
        }
        $this->sourcePath = craft()->path->getRuntimePath() . 'imager/' . $parsedDirname . '/';
        $this->targetPath = craft()->imager->getSetting('imagerSystemPath') . $parsedDirname . '/';
        $this->targetUrl = craft()->imager->getSetting('imagerUrl') . $parsedDirname . '/';
        $this->sourceFilename = $this->targetFilename = str_replace(' ', '-', $pathParts['basename']);
        // check if the temp path for remote files exists or can be created.
        if (!IOHelper::getRealPath($this->sourcePath)) {
            IOHelper::createFolder($this->sourcePath, craft()->config->get('defaultFolderPermissions'), true);
            if (!IOHelper::getRealPath($this->sourcePath)) {
                throw new Exception(Craft::t('Temp folder “{sourcePath}” does not exist and could not be created', array('sourcePath' => $this->sourcePath)));
            }
        }
        // check if the file is already downloaded
        if (!IOHelper::fileExists($this->sourcePath . $this->sourceFilename) || craft()->imager->getSetting('cacheDurationRemoteFiles') !== false && IOHelper::getLastTimeModified($this->sourcePath . $this->sourceFilename)->format('U') + craft()->imager->getSetting('cacheDurationRemoteFiles') < time()) {
            $this->_downloadFile($this->sourcePath . $this->sourceFilename, $image);
            if (!IOHelper::fileExists($this->sourcePath . $this->sourceFilename)) {
                throw new Exception(Craft::t('File could not be downloaded and saved to “{sourcePath}”', array('sourcePath' => $this->sourcePath)));
            }
        }
    }