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