]> BookStack Code Mirror - bookstack/blob - app/Uploads/Image.php
fix missing word
[bookstack] / app / Uploads / Image.php
1 <?php namespace BookStack\Uploads;
2
3 use BookStack\Entities\Page;
4 use BookStack\Ownable;
5 use Images;
6
7 class Image extends Ownable
8 {
9
10     protected $fillable = ['name'];
11
12     /**
13      * Get a thumbnail for this image.
14      * @param  int $width
15      * @param  int $height
16      * @param bool|false $keepRatio
17      * @return string
18      * @throws \Exception
19      */
20     public function getThumb($width, $height, $keepRatio = false)
21     {
22         return Images::getThumbnail($this, $width, $height, $keepRatio);
23     }
24
25     /**
26      * Get the page this image has been uploaded to.
27      * Only applicable to gallery or drawio image types.
28      * @return Page|null
29      */
30     public function getPage()
31     {
32         return $this->belongsTo(Page::class, 'uploaded_to')->first();
33     }
34 }