3 namespace BookStack\Uploads;
5 use BookStack\Entities\Models\Page;
7 use BookStack\Traits\HasCreatorAndUpdater;
11 * @property string $name
12 * @property string $url
13 * @property string $path
14 * @property string $type
15 * @property int $uploaded_to
16 * @property int $created_by
17 * @property int $updated_by
19 class Image extends Model
21 use HasCreatorAndUpdater;
23 protected $fillable = ['name'];
24 protected $hidden = [];
27 * Get a thumbnail for this image.
31 public function getThumb(int $width, int $height, bool $keepRatio = false): string
33 return app()->make(ImageService::class)->getThumbnail($this, $width, $height, $keepRatio);
37 * Get the page this image has been uploaded to.
38 * Only applicable to gallery or drawio image types.
40 public function getPage(): ?Page
42 return $this->belongsTo(Page::class, 'uploaded_to')->first();