Convert to image handler hook based viewer insertion
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -16,12 +16,25 @@ class GlModelViewer extends ImageHandler {
|
||||
}
|
||||
|
||||
public static function onBeforePageDisplay(OutputPage $out) {
|
||||
preg_match('/(<a href="\S*?\.(glb|gltf"))/',$out->getHTML(),$findGltf);
|
||||
preg_match('/(<model-viewer src="\S*?\.(glb|gltf"))/',$out->getHTML(),$findGltf);
|
||||
if ($findGltf[0]) {
|
||||
$out->addModules('ext.glmv');
|
||||
}
|
||||
}
|
||||
|
||||
public static function onImageBeforeProduceHTML( DummyLinker &$linker, Title &$title, &$file, array &$frameParams, array &$handlerParams, &$time, &$result, Parser $parser, string &$query, &$widthOption ) {
|
||||
if ($file->getMimeType() !== 'model/gltf-binary') {
|
||||
return true;
|
||||
}
|
||||
$result = '<model-viewer src=' . $file->getFullUrl() . '></model-viewer>';
|
||||
#echo '<script>';
|
||||
#GlModelViewer::console_log($handlerParams);
|
||||
#GlModelViewer::console_log($frameParams);
|
||||
#GlModelViewer::console_log($file->getDescriptionText());
|
||||
#echo '</script>';
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function console_log($data, $add_script_tags = false) {
|
||||
$command = 'console.log('. json_encode($data, JSON_HEX_TAG).');';
|
||||
if ($add_script_tags) {
|
||||
|
||||
Reference in New Issue
Block a user