PHP Class BookStack\Services\ImageService

Inheritance: extends UploadService
Mostra file Open project: ssddanbrown/bookstack

Protected Properties

Property Type Description
$cache
$imageTool
$storageUrl

Public Methods

Method Description
__construct ( Intervention\Image\ImageManager $imageTool, Illuminate\Contracts\Filesystem\Factory $fileSystem, Illuminate\Contracts\Cache\Repository $cache ) ImageService constructor.
destroyImage ( Image $image ) : boolean Destroys an Image object along with its files and thumbnails.
getThumbnail ( Image $image, integer $width = 220, integer $height = 220, boolean $keepRatio = false ) : string Get the thumbnail for an image.
saveNewFromUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, string $type, integer $uploadedTo ) : mixed Saves a new image from an upload.
saveUserGravatar ( User $user, integer $size = 500 ) : mixed Save a gravatar image and set a the profile image for a user.

Protected Methods

Method Description
getPath ( Image $image ) : mixed | string Get the storage path, Dependant of storage type.

Private Methods

Method Description
getPublicUrl ( string $filePath ) : string Gets a public facing url for an image by checking relevant environment variables.
saveNew ( string $imageName, string $imageData, string $type, integer $uploadedTo ) : Image Saves a new image
saveNewFromUrl ( $url, string $type, boolean | string $imageName = false ) : mixed Gets an image from url and saves it to the database.

Method Details

__construct() public method

ImageService constructor.
public __construct ( Intervention\Image\ImageManager $imageTool, Illuminate\Contracts\Filesystem\Factory $fileSystem, Illuminate\Contracts\Cache\Repository $cache )
$imageTool Intervention\Image\ImageManager
$fileSystem Illuminate\Contracts\Filesystem\Factory
$cache Illuminate\Contracts\Cache\Repository

destroyImage() public method

Destroys an Image object along with its files and thumbnails.
public destroyImage ( Image $image ) : boolean
$image BookStack\Image
return boolean

getPath() protected method

Get the storage path, Dependant of storage type.
protected getPath ( Image $image ) : mixed | string
$image BookStack\Image
return mixed | string

getThumbnail() public method

If $keepRatio is true only the width will be used. Checks the cache then storage to avoid creating / accessing the filesystem on every check.
public getThumbnail ( Image $image, integer $width = 220, integer $height = 220, boolean $keepRatio = false ) : string
$image BookStack\Image
$width integer
$height integer
$keepRatio boolean
return string

saveNewFromUpload() public method

Saves a new image from an upload.
public saveNewFromUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, string $type, integer $uploadedTo ) : mixed
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
$type string
$uploadedTo integer
return mixed

saveUserGravatar() public method

Save a gravatar image and set a the profile image for a user.
public saveUserGravatar ( User $user, integer $size = 500 ) : mixed
$user BookStack\User
$size integer
return mixed

Property Details

$cache protected_oe property

protected $cache

$imageTool protected_oe property

protected $imageTool

$storageUrl protected_oe property

protected $storageUrl