Add basic thumbnail handling with static image

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-10-30 09:28:29 -07:00
parent 11bac465d9
commit 64140b7cd9
5 changed files with 28 additions and 23 deletions

View File

@@ -18,10 +18,10 @@ class GlModelTransformOutput extends MediaTransformOutput {
public function __construct($file, $parameters) {
$this->file = $file;
$this->parameters = $parameters;
$this->width = (isset($parameters['width'])) ? $parameters['width'] : '800';
$this->height = (isset($parameters['height'])) ? $parameters['height'] : (int)($this->width * .75);
$this->width = $parameters['width'];
$this->height = $parameters['height'];
$this->url = $file->getFullUrl();
$this->thumb = isset($parameters['isFilePageThumb']);
$this->thumb = isset($parameters['isFilePageThumb']) && $parameters['isFilePageThumb'];
}
/**
@@ -43,7 +43,13 @@ class GlModelTransformOutput extends MediaTransformOutput {
*/
public function toHtml($options = []) {
if ($this->thumb) {
return Html::rawElement('span',['class' => 'fake-thumbnail'],'Gltf model thumbnail');
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
$thumbUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/model_thumb.svg';
$attrMenuImg = array (
'src' => $thumbUrl,
'style' => 'width: ' . $this->width . 'px; height: ' . $this->height . 'px;'
);
return Html::rawElement('img', $attrMenuImg, '');
}
if (isset($options['img-class'])) {