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:
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user