From 04567ffd80881cb370f857a31590e051d249053c Mon Sep 17 00:00:00 2001
From: Fabian Galinski <fabian@sgalinski.de>
Date: Thu, 29 Oct 2020 20:03:05 +0100
Subject: [PATCH] [TASK] Improvement of the width calculation

---
 Resources/Private/Language/de.locallang.xlf    |  4 ++--
 Resources/Private/Language/locallang.xlf       |  2 +-
 Resources/Public/JavaScript/youtubeLightbox.js | 11 +++++++----
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf
index 34562c7..d878ef7 100644
--- a/Resources/Private/Language/de.locallang.xlf
+++ b/Resources/Private/Language/de.locallang.xlf
@@ -26,8 +26,8 @@
 				<target><![CDATA[Aspect Ratio (nur genutzt, wenn der Thumbnail-Typ dies prüfen soll)]]></target>
 			</trans-unit>
 			<trans-unit id="flexform.disableLightbox" approved="yes">
-				<source><![CDATA[Replace the thumbnail with the video and disable the lightbox?]]></source>
-				<target><![CDATA[Das Thumbnail durch das Video ersetzen und die Lightbox deaktivieren?]]></target>
+				<source><![CDATA[Replace the thumbnail with the video and disable the lightbox]]></source>
+				<target><![CDATA[Das Thumbnail durch das Video ersetzen und die Lightbox deaktivieren]]></target>
 			</trans-unit>
 			<trans-unit id="flexform.id" approved="yes">
 				<source><![CDATA[ID of Channel (UC), Playlist (PL) or Single Video (youtube.com/watch?v=%ID%)]]></source>
diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf
index d6f0e46..b20d2cd 100644
--- a/Resources/Private/Language/locallang.xlf
+++ b/Resources/Private/Language/locallang.xlf
@@ -21,7 +21,7 @@
 				<source><![CDATA[Aspect Ratio (only used if thumbnail type is set to check that)]]></source>
 			</trans-unit>
 			<trans-unit id="flexform.disableLightbox">
-				<source><![CDATA[Replace the thumbnail with the video and disable the lightbox?]]></source>
+				<source><![CDATA[Replace the thumbnail with the video and disable the lightbox]]></source>
 			</trans-unit>
 			<trans-unit id="flexform.id">
 				<source><![CDATA[ID of Channel (UC), Playlist (PL) or Single Video (youtube.com/watch?v=%ID%)]]></source>
diff --git a/Resources/Public/JavaScript/youtubeLightbox.js b/Resources/Public/JavaScript/youtubeLightbox.js
index a266c31..c14d82a 100644
--- a/Resources/Public/JavaScript/youtubeLightbox.js
+++ b/Resources/Public/JavaScript/youtubeLightbox.js
@@ -45,14 +45,17 @@ module.exports = function() {
 		let $youtubeItem = $(event.currentTarget);
 
 		// This needs to be done, because the height of inline elements is always 0, if on auto...
-		$youtubeItem.css('display', 'inherit');
+		$youtubeItem.css('display', 'block');
 
 		let queryString = prepareVideoUrl($youtubeItem.attr('href')),
+			width = $youtubeItem.outerWidth() + 'px',
 			height = $youtubeItem.outerHeight() + 'px';
-		$youtubeItem.replaceWith('<div class="sg-youtube-item sg-card-shadow" style="height: ' + height + '"><iframe ' +
-			'width="100%" height="' + height + '" ' +
+		$youtubeItem.replaceWith('<div class="sg-youtube-item sg-card-shadow" ' +
+			'style="height: ' + height + '; width: ' + width + ';"><iframe ' +
+			'width="' + width + '" height="' + height + '" ' +
 			'src="https://www.youtube-nocookie.com/embed/' + queryString + '" frameborder="0" ' +
-			'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>')
+			'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" ' +
+			'allowfullscreen></iframe></div>')
 	}
 
 	/**
-- 
GitLab