From 05575f81a45aa91ea361ec0b4dc941bbe6ef3a36 Mon Sep 17 00:00:00 2001 From: "H. C. Kruse" Date: Sun, 28 Apr 2024 14:11:36 +0200 Subject: [PATCH] fix: Don't try to transform bool Fixes #93 --- includes/Media/VideoHandler.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/includes/Media/VideoHandler.php b/includes/Media/VideoHandler.php index bf227fe..ad7254e 100644 --- a/includes/Media/VideoHandler.php +++ b/includes/Media/VideoHandler.php @@ -73,21 +73,23 @@ public function normaliseParams( $image, &$params ): bool { if ( $title !== null && $title->exists() ) { $coverFile = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title ); - $transform = $coverFile->transform( [ 'width' => $params['width'] ] ); - try { - $params['posterUrl'] = MediaWikiServices::getInstance()->getUrlUtils()->expand( - $transform->getUrl() - ); + if ( !$coverFile !== false ) { + $transform = $coverFile->transform( [ 'width' => $params['width'] ] ); - } catch ( Exception $e ) { - unset( $params['poster'], $params['posterUrl'] ); + try { + $params['posterUrl'] = MediaWikiServices::getInstance()->getUrlUtils()->expand( + $transform->getUrl() + ); + } catch ( Exception $e ) { + unset( $params['posterUrl'] ); + } } - } else { - unset( $params['poster'] ); } } + unset( $params['poster'] ); + if ( isset( $params['lazy'] ) ) { $params['lazy'] = true; } else {