Use poster for thumbnail
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -46,14 +46,28 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
* @return string HTML
|
* @return string HTML
|
||||||
*/
|
*/
|
||||||
public function toHtml($options = []) {
|
public function toHtml($options = []) {
|
||||||
|
$descriptText = $this->file->getDescriptionText();
|
||||||
if ($this->thumb) {
|
if ($this->thumb) {
|
||||||
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
|
preg_match('/<pre>([\S\s]*?)<\/pre>/',$descriptText,$modelDescript);
|
||||||
$thumbUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/model_thumb.svg';
|
$metadata = json_decode($modelDescript[1], true);
|
||||||
$attrMenuImg = array (
|
$poster = $metadata['viewerConfig'][$this->view]['poster'] ?? false;
|
||||||
|
|
||||||
|
if ($poster) {
|
||||||
|
$posterFile = MediaWikiServices::getInstance()->getRepoGroup()->findFile(`File:` . $poster);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($poster && $posterFile) {
|
||||||
|
$thumbUrl = $posterFile->getFullUrl();
|
||||||
|
} else {
|
||||||
|
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
|
||||||
|
$thumbUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/model_thumb.svg';
|
||||||
|
}
|
||||||
|
|
||||||
|
$attrThumbImg = array (
|
||||||
'src' => $thumbUrl,
|
'src' => $thumbUrl,
|
||||||
'style' => 'width: ' . $this->width . 'px; height: ' . $this->height . 'px;'
|
'style' => 'width: ' . $this->width . 'px; height: ' . $this->height . 'px; ' . 'object-fit: contain;'
|
||||||
);
|
);
|
||||||
return Html::rawElement('img', $attrMenuImg, '');
|
return Html::rawElement('img', $attrThumbImg, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['img-class'])) {
|
if (isset($options['img-class'])) {
|
||||||
@@ -64,7 +78,7 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
$this->parameters['preview'] = $options['preview'];
|
$this->parameters['preview'] = $options['preview'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::buildViewer($this->file->getDescriptionText(),$this->url,$this->parameters);
|
return self::buildViewer($descriptText,$this->url,$this->parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user