diff --git a/extension.json b/extension.json
index 43e465f..9f0f786 100644
--- a/extension.json
+++ b/extension.json
@@ -17,7 +17,6 @@
"MimeMagicInit": "MediaWiki\\Extension\\GlModelViewer\\GlModelHooks::onMimeMagicInit",
"MimeMagicImproveFromExtension": "MediaWiki\\Extension\\GlModelViewer\\GlModelHooks::onMimeMagicImproveFromExtension",
"BeforePageDisplay": "MediaWiki\\Extension\\GlModelViewer\\GlModelHooks::onBeforePageDisplay",
- "ImageOpenShowImageInlineBefore": "MediaWiki\\Extension\\GlModelViewer\\GlModelHooks::onImageOpenShowImageInlineBefore",
"AlternateEditPreview": "MediaWiki\\Extension\\GlModelViewer\\GlModelHooks::onAlternateEditPreview"
},
"ResourceFileModulePaths": {
diff --git a/includes/GlModelHandler.php b/includes/GlModelHandler.php
index 472ef8a..7777894 100644
--- a/includes/GlModelHandler.php
+++ b/includes/GlModelHandler.php
@@ -36,6 +36,18 @@ class GlModelHandler extends ImageHandler {
* @return MediaTransformOutput
*/
public function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0) {
+ $params['isFilePageThumb'] = false;
+ if (!isset($params['width']) || $params['width'] == 0) {
+ $params['width'] = 800;
+ }
+ if (!isset($params['height']) || $params['height'] == 0) {
+ $params['height'] = 600;
+ }
+
+ if ($params['width'] <= 300 || $params['height'] <= 300) {
+ $params['isFilePageThumb'] = true;
+ }
+
return new GlModelTransformOutput($image, $params);
}
@@ -47,7 +59,10 @@ class GlModelHandler extends ImageHandler {
* @return bool
*/
public function validateParam( $name, $value ) {
- if (in_array($name, ['width', 'height'])) {
+ echo '';
+ if (in_array($name, ['width', 'height'])) {
return $value > 0;
} else if (in_array($name, ['view', 'hsset'])) {
return true;
diff --git a/includes/GlModelHooks.php b/includes/GlModelHooks.php
index 3df33c7..f969621 100644
--- a/includes/GlModelHooks.php
+++ b/includes/GlModelHooks.php
@@ -52,22 +52,6 @@ class GlModelHooks {
}
}
- /**
- * MWHook: Display model on file page
- *
- * @see https://www.mediawiki.org/wiki/Manual:Hooks/ImageOpenShowImageInlineBefore
- *
- * @param ImagePage $imagepage information regarding the page for the image file
- * @param OutputPage $out compiled page html and manipulation methods
- */
- public static function onImageOpenShowImageInlineBefore( $imagepage, $out ){
- $file = $imagepage->getFile();
- if ($file->getMimeType() == 'model/gltf-binary') {
- $out->clearHTML();
- $out->addWikiTextAsContent('[[' . $file->getTitle()->getFullText() . '|800x600px]]');
- }
- }
-
/**
* MWHook: Display model when model file page edits are previewed
*
@@ -88,7 +72,7 @@ class GlModelHooks {
$out = $editor->getContext()->getOutput();
$out->addModules('ext.glmv');
- $mvTransform = $file->transform([ 'width' => '800', 'hight' => '600']);
+ $mvTransform = $file->transform([ 'width' => '800', 'hight' => '600', 'view' => 'test']);
$previewViewer = $mvTransform->toHtml([ 'preview' => true]);
$addButtonAttr = array(
diff --git a/includes/GlModelTransformOutput.php b/includes/GlModelTransformOutput.php
index 5c044f5..23b75ff 100644
--- a/includes/GlModelTransformOutput.php
+++ b/includes/GlModelTransformOutput.php
@@ -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'])) {
diff --git a/resources/model_thumb.svg b/resources/model_thumb.svg
new file mode 100644
index 0000000..fd20797
--- /dev/null
+++ b/resources/model_thumb.svg
@@ -0,0 +1 @@
+
\ No newline at end of file