diff --git a/includes/GlModelTransformOutput.php b/includes/GlModelTransformOutput.php
index c521e22..d8ca64e 100644
--- a/includes/GlModelTransformOutput.php
+++ b/includes/GlModelTransformOutput.php
@@ -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, '
');
+ }
+
//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);
}
/**
diff --git a/modules/glmv.css b/modules/glmv.css
index fe8bddf..1b604b6 100644
--- a/modules/glmv.css
+++ b/modules/glmv.css
@@ -185,6 +185,12 @@
margin: 2px;
}
+.glmv-file-link {
+ position: absolute;
+ right: 0;
+ bottom: 0;
+}
+
@media (pointer: coarse) {
.Hotspot {
width: 1.25em;
diff --git a/resources/file_link.svg b/resources/file_link.svg
new file mode 100644
index 0000000..204a4ec
--- /dev/null
+++ b/resources/file_link.svg
@@ -0,0 +1 @@
+
\ No newline at end of file