Add model previews on upload (#27)

Closes #22

This modifies the upload form to allow for a preview of models.

Reviewed-on: #27
This commit is contained in:
2024-11-04 00:02:48 +00:00
parent a3a9902070
commit fc30b09d16
4 changed files with 81 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
namespace MediaWiki\Extension\GlModelViewer;
use MediaWiki\MediaWikiServices;
use RequestContext;
use Html;
use ParserOutput;
@@ -100,6 +101,22 @@ class GlModelHooks {
return false;
}
/**
* MWHook: Occurs after the descriptor for the upload form as been assembled.
*
* @param $descriptor the HTMLForm descriptor
*/
public static function onUploadFormInitDescriptor( $descriptor ) {
$context = RequestContext::getMain();
$out = $context->getOutput();
$mvScriptAttr = array(
'src' => 'https://ajax.googleapis.com/ajax/libs/model-viewer/3.5.0/model-viewer.min.js',
'type' => 'module'
);
$out->addHeadItems(Html::rawElement('script',$mvScriptAttr));
$out->addModules('ext.glmv.upl');
}
/**
* Small helper function to display information on the browser console
*