Add download image button

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-11-03 20:44:05 -07:00
parent 80759edbad
commit 7a53ef8de8
2 changed files with 34 additions and 2 deletions

View File

@@ -65,7 +65,8 @@ class GlModelHooks {
* @return bool|void True to continue default processing or false to abort for custom processing
*/
public static function onAlternateEditPreview( $editor, $content, string &$previewHTML, ?ParserOutput &$parserOutput ) {
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile($editor->getTitle());
$title = $editor->getTitle();
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile($title);
if (!$file || $file->getMimeType() !== 'model/gltf-binary') {
return true;
}
@@ -91,10 +92,16 @@ class GlModelHooks {
'onclick' => 'readyDelHotspot()'
);
$dldButtonAttr = array(
'class' => 'preview-button MakeImage',
'onclick' => 'downloadImage("' . $title . '")'
);
$addHsButton = array(
Html::rawElement('button',$addButtonAttr,'Add a new hotspot'),
Html::rawElement('button',$readButtonAttr,'Update hotspots'),
Html::rawElement('button',$delButtonAttr,'Delete hotspot')
Html::rawElement('button',$delButtonAttr,'Delete hotspot'),
Html::rawElement('button',$dldButtonAttr,'Download image')
);
$previewHTML = Html::rawElement('div',NULL,$previewViewer.implode($addHsButton));