| @@ 10-45 (lines=36) @@ | ||
| 7 | /** |
|
| 8 | * This is the model class for Image content type. |
|
| 9 | */ |
|
| 10 | class Image extends Media |
|
| 11 | { |
|
| 12 | const TYPE = 'image'; |
|
| 13 | const TYPE_PATH = 'images/'; |
|
| 14 | ||
| 15 | public $html = '<img src="%data%" class="image" />'; |
|
| 16 | public $css = '%field% { text-align: center; } %field% img { position: absolute; top: 0; left: 0; bottom: 0; right: 0; margin: auto; max-height: 100%; max-width: 100%; }'; |
|
| 17 | public $input = 'url'; |
|
| 18 | public $output = 'url'; |
|
| 19 | public $usable = true; |
|
| 20 | public $exemple = '@web/images/image.preview.jpg'; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * {@inheritdoc} |
|
| 24 | */ |
|
| 25 | public function __construct($config = []) |
|
| 26 | { |
|
| 27 | parent::__construct($config); |
|
| 28 | $this->name = Yii::t('app', 'Image'); |
|
| 29 | $this->description = Yii::t('app', 'Direct link to an image on an internet website. Hosted image is usually more appropriate.'); |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * {@inheritdoc} |
|
| 34 | */ |
|
| 35 | public static function validateFile($realFilepath) |
|
| 36 | { |
|
| 37 | $mediainfo = self::getMediaInfo($realFilepath); |
|
| 38 | ||
| 39 | if (count($mediainfo->getImages())) { |
|
| 40 | return true; |
|
| 41 | } |
|
| 42 | ||
| 43 | return false; |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 10-46 (lines=37) @@ | ||
| 7 | /** |
|
| 8 | * This is the model class for Video content type. |
|
| 9 | */ |
|
| 10 | class Video extends Media |
|
| 11 | { |
|
| 12 | const TYPE = 'video'; |
|
| 13 | const TYPE_PATH = 'videos/'; |
|
| 14 | ||
| 15 | public $html = '<iframe src="%data%" />'; |
|
| 16 | public $css = '%field% > iframe { height: 100%; width: 100%; }'; |
|
| 17 | public $appendParams = '_win=%x1%,%y1%,%x2%,%y2%;_aspect-mode=letterbox;_duration=%dur%'; |
|
| 18 | public $usable = true; |
|
| 19 | public $input = 'url'; |
|
| 20 | public $output = 'url'; |
|
| 21 | public $exemple = '@web/images/video.preview.jpg'; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * {@inheritdoc} |
|
| 25 | */ |
|
| 26 | public function __construct($config = []) |
|
| 27 | { |
|
| 28 | parent::__construct($config); |
|
| 29 | $this->name = Yii::t('app', 'Video'); |
|
| 30 | $this->description = Yii::t('app', 'Direct link to a video on an internet website. Hosted video is usually more appropriate.'); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * {@inheritdoc} |
|
| 35 | */ |
|
| 36 | public static function validateFile($realFilepath) |
|
| 37 | { |
|
| 38 | $mediainfo = self::getMediaInfo($realFilepath); |
|
| 39 | ||
| 40 | if ($mediainfo && count($mediainfo->getVideos())) { |
|
| 41 | return true; |
|
| 42 | } |
|
| 43 | ||
| 44 | return false; |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||