Add file page link model when not on file page
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@ namespace MediaWiki\Extension\GlModelViewer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaTransformOutput;
|
||||
use ConfigFactory;
|
||||
use OutputPage;
|
||||
use RequestContext;
|
||||
use Html;
|
||||
|
||||
class GlModelTransformOutput extends MediaTransformOutput {
|
||||
@@ -99,6 +99,8 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
//Gather basic data
|
||||
$hsSet = (isset($metadata['annotationSets']) && isset($metadata['annotationSets'][$this->hsset])) ? $this->hsset : 'default';
|
||||
$view = (isset($metadata['viewerConfig']) && isset($metadata['viewerConfig'][$this->view])) ? $this->view : 'default';
|
||||
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
|
||||
$context = RequestContext::getMain();
|
||||
|
||||
//Handle annotations and annotation sets
|
||||
if (isset($metadata['annotations'])) {
|
||||
@@ -162,7 +164,6 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
if ($posterFile) {
|
||||
$attrModelView['poster'] = $posterFile->getFullUrl();
|
||||
$attrModelView['reveal'] = 'manual';
|
||||
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
|
||||
$interactUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/interact.svg';
|
||||
$attrInteractButton = array (
|
||||
'class' => 'glmv-act-button',
|
||||
@@ -184,6 +185,16 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
$elModel = Html::rawElement('model-viewer', $attrModelView, $hotspotHtml);
|
||||
$elMenu = self::buildViewMenu();
|
||||
|
||||
$elFileLink = '';
|
||||
if (!isset($viewParams['preview']) && $context->getTitle() != $this->file->getTitle()) {
|
||||
$attrFileLink = array(
|
||||
'class' => 'glmv-file-link',
|
||||
'href' => $this->file->getDescriptionUrl()
|
||||
);
|
||||
$fileLinkUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/file_link.svg';
|
||||
$elFileLink = Html::rawElement('a', $attrFileLink, '<img src="' . $fileLinkUrl . '"></image>');
|
||||
}
|
||||
|
||||
//Render and return container element with model-viewer
|
||||
$attrContainer = array(
|
||||
'class' => 'glmv-container',
|
||||
@@ -193,7 +204,7 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
'onfullscreenchange' => 'toggleFullScreen(event)'
|
||||
);
|
||||
|
||||
return Html::rawElement('div', $attrContainer, $elModel . $elMenu . $interactButton);
|
||||
return Html::rawElement('div', $attrContainer, $elModel . $elMenu . $elFileLink . $interactButton);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -185,6 +185,12 @@
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.glmv-file-link {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
.Hotspot {
|
||||
width: 1.25em;
|
||||
|
||||
1
resources/file_link.svg
Normal file
1
resources/file_link.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="#5f6368"><path d="M263.72-96Q234-96 213-117.15T192-168v-624q0-29.7 21.16-50.85Q234.32-864 264.04-864h432.24Q726-864 747-842.85T768-792v624q0 29.7-21.16 50.85Q725.68-96 695.96-96H263.72Zm.28-72h432v-624H264v624Zm48-72h336L528-400l-84 112-48-64-84 112Zm-48 72v-624 624Z"/></svg>
|
||||
|
After Width: | Height: | Size: 374 B |
Reference in New Issue
Block a user