BookStack\Services\ImageService::saveNewFromUrl PHP Method

saveNewFromUrl() private method

Gets an image from url and saves it to the database.
private saveNewFromUrl ( $url, string $type, boolean | string $imageName = false ) : mixed
$url
$type string
$imageName boolean | string
return mixed
    private function saveNewFromUrl($url, $type, $imageName = false)
    {
        $imageName = $imageName ? $imageName : basename($url);
        $imageData = file_get_contents($url);
        if ($imageData === false) {
            throw new \Exception('Cannot get image from ' . $url);
        }
        return $this->saveNew($imageName, $imageData, $type);
    }