Skip to content

Commit 0dbdd9a

Browse files
committed
Merge branch 'release/v3.2.5'
2 parents 0b69492 + e1f1225 commit 0dbdd9a

File tree

7 files changed

+38
-17
lines changed

7 files changed

+38
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "starcitizenwiki/embedvideo",
3-
"version": "3.2.4",
3+
"version": "3.2.5",
44
"type": "mediawiki-extension",
55
"description": "Adds a parser function embedding video from popular sources.",
66
"license": "MIT",

extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "EmbedVideo",
3-
"version": "3.2.4",
3+
"version": "3.2.5",
44
"author": [
55
"[https://www.mediawiki.org/wiki/User:Octfx Octfx]",
66
"[https://www.mediawiki.org/wiki/User:Alistair3149 Alistair3149]",

i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"embedvideo-error-id": "EmbedVideo received the bad id \"$2\" for the service \"$1\".",
2828
"embedvideo-error-width": "EmbedVideo received the bad width parameter \"$1\".",
2929
"embedvideo-error-height": "EmbedVideo received the bad height parameter \"$1\".",
30-
"embedvideo-error-alignment": "EmbedVideo was given an illegal value for the alignment parameter \"$1\". Valid values are \"left\", \"center\", \"right\", or \"inline\".",
30+
"embedvideo-error-alignment": "EmbedVideo was given an illegal value for the alignment parameter \"$1\". Valid values are \"left\", \"center\", or \"right\".",
3131
"embedvideo-error-valignment": "EmbedVideo was given an illegal value for the valignment parameter \"$1\". Valid values are \"top\", \"middle\", \"bottom\", or \"baseline\".",
3232
"embedvideo-error-urlargs": "EmbedVideo received a list of URL arguments that contained malformed data or blank arguments.",
3333
"embedvideo-error-unknown": "EmbedVideo encountered an unknown error while trying to generate this video embed block. ($1)",

i18n/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"embedvideo-error-id": "« EmbedVideo » a reçu l’identifiant erroné « $2 » pour le service « $1 ».",
3333
"embedvideo-error-width": "« EmbedVideo » a reçu une valeur erronée « $1 » pour le paramètre de largeur.",
3434
"embedvideo-error-height": "« EmbedVideo » a reçu une valeur erronée « $1 » pour le paramètre de hauteur.",
35-
"embedvideo-error-alignment": "« EmbedVideo » a reçu une valeur une valeur erronée « $1 » pour le paramètre d’alignement. Les valeurs valides sont « left » (gauche), « center » (centre), « right » (droite) ou « inline » (en ligne).",
35+
"embedvideo-error-alignment": "« EmbedVideo » a reçu une valeur une valeur erronée « $1 » pour le paramètre d’alignement. Les valeurs valides sont « left » (gauche), « center » (centre), ou « right » (droite).",
3636
"embedvideo-error-valignment": "« EmbedVideo » a reçu une valeur une valeur erronée « $1 » pour le paramètre d’alignement vertical. Les valeurs valides sont « top » (haut), « middle » (milieu), « bottom » (bas) ou « baseline » (ligne de base).",
3737
"embedvideo-error-urlargs": "« EmbedVideo » a reçu une liste d’arguments d’URL qui contiennent des données malformées ou des arguments vides.",
3838
"embedvideo-error-unknown": "« EmbedVideo » a rencontré une erreur inconnue en essayant de générer ce bloc d’intégration vidéo. ($1)",

includes/EmbedService/EmbedHtmlFormatter.php

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,26 @@ public static function toHtml( AbstractEmbedService $service, array $config = []
7171
}
7272
}
7373

74+
$iframeConfig = '';
75+
try {
76+
$consent = MediaWikiServices::getInstance()
77+
->getConfigFactory()
78+
->makeConfig( 'EmbedVideo' )
79+
->get( 'EmbedVideoRequireConsent' );
80+
if ( $consent === true ) {
81+
$attributes = $service->getIframeAttributes();
82+
$attributes['width'] = $service->getWidth();
83+
$attributes['height'] = $service->getHeight();
84+
$attributes['src'] = $service->getUrl();
85+
$iframeConfig = sprintf(
86+
"data-iframeconfig='%s'",
87+
json_encode( $attributes, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES )
88+
);
89+
}
90+
} catch ( JsonException | ConfigException $e ) {
91+
//
92+
}
93+
7494
/**
7595
* TODO: Sync syntax with core image syntax
7696
* @see: https://www.mediawiki.org/wiki/Help:Images
@@ -83,7 +103,7 @@ public static function toHtml( AbstractEmbedService $service, array $config = []
83103
* @see https://www.mediawiki.org/wiki/Specs/HTML/2.7.0#Audio/Video
84104
*/
85105
$template = <<<HTML
86-
<figure class="%s" data-service="%s" %s><!--
106+
<figure class="%s" data-service="%s" %s %s><!--
87107
--><span class="embedvideo-wrapper" %s>%s%s</span>%s
88108
</figure>
89109
HTML;
@@ -92,6 +112,7 @@ public static function toHtml( AbstractEmbedService $service, array $config = []
92112
$template,
93113
$config['class'] ?? '',
94114
$config['service'] ?? '',
115+
$iframeConfig,
95116
$inlineStyles['container'],
96117
$inlineStyles['wrapper'],
97118
( $config['withConsent'] ?? false ) === true ? self::makeConsentContainerHtml( $service ) : '',
@@ -127,13 +148,10 @@ public static function makeIframe( AbstractEmbedService $service ): string {
127148
->makeConfig( 'EmbedVideo' )
128149
->get( 'EmbedVideoRequireConsent' );
129150
if ( $consent === true ) {
130-
$attributes['src'] = $service->getUrl();
131-
return sprintf(
132-
'<div data-iframeconfig=\'%s\'></div>',
133-
json_encode( $attributes, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES )
134-
);
151+
// Iframe is created through JS
152+
return '';
135153
}
136-
} catch ( JsonException | ConfigException $e ) {
154+
} catch ( ConfigException $e ) {
137155
//
138156
}
139157

includes/EmbedVideo.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ private function setContainer( $container ): bool {
406406
private function setAlignment( $alignment ): bool {
407407
if ( !empty( $alignment ) && in_array( $alignment, [ 'left', 'right', 'center', 'none' ], true ) ) {
408408
$this->alignment = $alignment;
409-
} elseif ( !empty( $alignment ) ) {
409+
} elseif ( !empty( $alignment ) && $alignment !== 'inline' ) {
410+
// 'inline' is removed since v3.2.3, but kept for backwards compatibility
411+
// TODO: Remove check after some releases
410412
return false;
411413
}
412414

resources/ext.embedVideo.consent.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@
9292
};
9393

9494
mw.hook( 'wikipage.content' ).add( () => {
95-
document.querySelectorAll('.embedvideo-wrapper').forEach(function (wrapper) {
95+
document.querySelectorAll('.embedvideo').forEach(function (ev) {
96+
const wrapper = ev.querySelector('.embedvideo-wrapper');
97+
9698
const makeIframe = function (event) {
97-
wrapper.removeChild(iframeConfigEl);
9899
const iframe = document.createElement('iframe');
99100

100101
for (const [key, value] of Object.entries(iframeConfig)) {
@@ -115,13 +116,13 @@
115116

116117
/** @type HTMLDivElement|null */
117118
const consentDiv = wrapper.querySelector('.embedvideo-consent');
118-
const iframeConfigEl = wrapper.querySelector('[data-iframeconfig]');
119+
let iframeConfig = ev.dataset.iframeconfig;
119120

120-
if (consentDiv === null || iframeConfigEl === null) {
121+
if (consentDiv === null || iframeConfig === null) {
121122
return;
122123
}
123124

124-
const iframeConfig = JSON.parse(iframeConfigEl.dataset.iframeconfig);
125+
iframeConfig = JSON.parse(iframeConfig);
125126

126127
const loader = consentDiv.querySelector('.embedvideo-loader');
127128
const privacyNotice = consentDiv.querySelector('.embedvideo-privacyNotice');

0 commit comments

Comments
 (0)