]> BookStack Code Mirror - bookstack/blob - app/Uploads/Image.php
Added tests and translations for dark-mode components
[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     protected $hidden = [];
12
13     /**
14      * Get a thumbnail for this image.
15      * @param  int $width
16      * @param  int $height
17      * @param bool|false $keepRatio
18      * @return string
19      * @throws \Exception
20      */
21     public function getThumb($width, $height, $keepRatio = false)
22     {
23         return Images::getThumbnail($this, $width, $height, $keepRatio);
24     }
25
26     /**
27      * Get the page this image has been uploaded to.
28      * Only applicable to gallery or drawio image types.
29      * @return Page|null
30      */
31     public function getPage()
32     {
33         return $this->belongsTo(Page::class, 'uploaded_to')->first();
34     }
35 }