mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-25 03:35:35 +00:00
![Dan Brown](/assets/img/avatar_default.png)
- Now changes the images directly for user, system & cover. - Extra permission checks added to edit & delete actions.
35 lines
778 B
PHP
35 lines
778 B
PHP
<?php namespace BookStack\Uploads;
|
|
|
|
use BookStack\Entities\Page;
|
|
use BookStack\Ownable;
|
|
use Images;
|
|
|
|
class Image extends Ownable
|
|
{
|
|
|
|
protected $fillable = ['name'];
|
|
|
|
/**
|
|
* Get a thumbnail for this image.
|
|
* @param int $width
|
|
* @param int $height
|
|
* @param bool|false $keepRatio
|
|
* @return string
|
|
* @throws \Exception
|
|
*/
|
|
public function getThumb($width, $height, $keepRatio = false)
|
|
{
|
|
return Images::getThumbnail($this, $width, $height, $keepRatio);
|
|
}
|
|
|
|
/**
|
|
* Get the page this image has been uploaded to.
|
|
* Only applicable to gallery or drawio image types.
|
|
* @return Page|null
|
|
*/
|
|
public function getPage()
|
|
{
|
|
return $this->belongsTo(Page::class, 'uploaded_to')->first();
|
|
}
|
|
}
|