Collect metadata from glb file

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-11-10 19:52:08 -07:00
parent 0e91a69d29
commit 0c5c1c61d3
7 changed files with 125 additions and 4 deletions

View File

@@ -42,9 +42,17 @@ class GlModelHooks {
* @param OutputPage $out compiled page html and manipulation methods
*/
public static function onBeforePageDisplay($out) {
preg_match('/(<model-viewer src="\S*?\.(glb|gltf"))/',$out->getHTML(),$findGltf);
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile($out->getTitle());
if ($file) {
echo '<script>';
self::console_log('Metadata:');
self::console_log($file->getMetadata());
echo '</script>';
}
preg_match('/(<model-viewer src="\S*?\.(glb|gltf"))/',$out->getHTML(),$findGltf);
if ($findGltf[0]) {
$out->addHeadItems(
$out->addHeadItems(
Html::rawElement(
'script',
array(