Skip to content

Commit e5c9efc

Browse files
committed
Version 1.2.13
- Add min screen size setting
1 parent 6d5b96d commit e5c9efc

15 files changed

+97
-65
lines changed

OharaYTEmbed.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" ?>
2-
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
2+
<!DOCTYPE modification SYSTEM "https://www.simplemachines.org/xml/modification">
33

4-
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
4+
<modification xmlns="https://www.simplemachines.org/xml/modification" xmlns:smf="https://www.simplemachines.org/">
55
<id>Suki:ohara_youtube_embed</id>
6-
<version>1.2.12</version>
6+
<version>1.2.13</version>
77

88
<file name="$sourcedir/Post.php">
99
<operation>

Sources/OharaYTEmbed.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
/*
44
* @package Ohara Youtube Embed mod
5-
* @version 1.2.12
5+
* @version 1.2.13
66
* @author Michel Mendiola <suki@missallsunday.com>
77
* @copyright Copyright (C) 2022 Michel Mendiola
88
* @license http://www.mozilla.org/MPL/ MPL 2.0
99
*/
1010

1111
if (!defined('SMF'))
12-
die('Hacking attempt...');
12+
die('No direct access...');
1313

1414
function OYTE_bbc_add_code(&$codes)
1515
{
@@ -153,6 +153,9 @@ function OYTE_settings(&$config_vars)
153153
$config_vars[] = $txt['OYTE_title'];
154154
$config_vars[] = array('check', 'OYTE_master', 'subtext' => $txt['OYTE_master_sub']);
155155
$config_vars[] = array('check', 'OYTE_autoEmbed', 'subtext' => $txt['OYTE_autoEmbed_sub']);
156+
$config_vars[] = array('int', 'OYTE_min_screen_size', 'subtext' => $txt['OYTE_min_screen_size_sub'], 'size' => 4);
157+
$config_vars[] = array('int', 'OYTE_video_width', 'subtext' => $txt['OYTE_video_width_sub'], 'size' => 4);
158+
$config_vars[] = array('int', 'OYTE_video_height', 'subtext' => $txt['OYTE_video_height_sub'], 'size' => 4);
156159
$config_vars[] = '';
157160
}
158161

@@ -203,7 +206,7 @@ function OYTE_Main($data)
203206
$result = '
204207
<div class="oharaEmbed youtube" id="oh_'. $videoID .'">
205208
<noscript>
206-
<a href="//www.youtube.com/watch?v='. $videoID .'">//www.youtube.com/watch?v='. $videoID . '</a>
209+
<a href="https://youtube.com/watch?v='. $videoID .'">https://youtube.com/watch?v='. $videoID . '</a>
207210
</noscript>
208211
</div>';
209212

@@ -223,19 +226,14 @@ function OYTE_Vimeo($data)
223226
require_once($sourcedir .'/Subs-Package.php');
224227

225228
// Construct the URL
226-
$oembed = 'https://vimeo.com/api/oembed.json?url=' . rawurlencode($data) . '&width='.
227-
(empty($modSettings['OYTE_video_width']) ? '480' : $modSettings['OYTE_video_width']) .
228-
'&height='. (empty($modSettings['OYTE_video_height']) ? '270' : $modSettings['OYTE_video_height']);
229+
$oembed = 'https://vimeo.com/api/oembed.json?url=' . rawurlencode($data);
229230

230231
//Attempts to fetch data from a URL, regardless of PHP's allow_url_fopen setting
231232
$jsonArray = json_decode(fetch_web_data($oembed), true);
232233

233234
if (!empty($jsonArray) && is_array($jsonArray) && !empty($jsonArray['html']))
234235
return '
235-
<div class="oharaEmbed vimeo">'. str_replace('<iframe', '<iframe width="'.
236-
(empty($modSettings['OYTE_video_width']) ? '480' : $modSettings['OYTE_video_width']) .
237-
'px" height="'. (empty($modSettings['OYTE_video_height']) ? '270' : $modSettings['OYTE_video_height']) .
238-
'px"', $jsonArray['html']) .'</div>';
236+
<div class="oharaEmbed vimeo">'. $jsonArray['html'].'</div>';
239237

240238
else
241239
return sprintf($txt['OYTE_unvalid_link'], 'vimeo');
@@ -257,7 +255,7 @@ function OYTE_Gifv($data)
257255

258256
if (strpos($data, 'http') === false || strpos($data, '.com') === false)
259257
return '
260-
<video class="oharaEmbed gifv" autoplay loop preload="auto" controls>
258+
<video class="gifv" autoplay loop preload="auto" controls>
261259
<source src="https://i.imgur.com/'. $data .'.webm" type="video/webm">
262260
<source src="https://i.imgur.com/'. $data .'.mp4" type="video/mp4">
263261
</video>';
@@ -338,10 +336,23 @@ function OYTE_css()
338336
{
339337
global $context, $settings, $modSettings;
340338

339+
$videoWidth = !empty($modSettings['OYTE_video_width']) ? $modSettings['OYTE_video_width'] : 480;
340+
$videoHeight = !empty($modSettings['OYTE_video_height']) ? $modSettings['OYTE_video_height'] : 270;
341+
$screenMinSize = !empty($modSettings['OYTE_min_screen_size']) ? $modSettings['OYTE_min_screen_size'] : 768;
342+
341343
// Add our css and js files. Dear and lovely mod authors, if you're going to use $context['html_headers'] MAKE SURE you append your data .= instead of re-declaring the var! and don't forget to add a new line and proper indentation too!
342344
$context['html_headers'] .= '
343345
<script type="text/javascript" src="'. $settings['default_theme_url'] .'/scripts/ohyoutube.js"></script>
344-
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url'] .'/css/oharaEmbed.css" />';
346+
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url'] .'/css/oharaEmbed.css" />
347+
<style>
348+
@media screen and (min-width: '. $screenMinSize .'px) {
349+
.oharaEmbed, .gifv, .oharaEmbed iframe, .oharaEmbed object, .oharaEmbed embed {
350+
max-width: '. $videoWidth .'px;
351+
max-height: '. $videoHeight .'px;
352+
padding-bottom: '. $videoHeight .'px;
353+
}
354+
}
355+
</style>';
345356
}
346357

347358
// DUH! WINNING!

Themes/default/css/oharaEmbed.css

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@
1616
display:block;
1717
}
1818

19-
@media (min-width: 1920px) {
20-
.oharaEmbed, .gifv {
21-
max-width: 1440px;
22-
}
23-
}
24-
@media (min-width: 3840px) {
25-
.oharaEmbed, .gifv{
26-
max-width: 2160px;
27-
}
28-
}
29-
@media (min-width: 2560px) {
30-
.oharaEmbed, .gifv {
31-
max-width: 1920px;
32-
}
33-
}
34-
3519
.oharaEmbed iframe, .oharaEmbed object, .oharaEmbed embed {
3620
position: absolute;
3721
top: 0;

Themes/default/languages/OharaYTEmbed.english-utf8.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
$txt['OYTE_master_sub'] = 'This is the master setting, it needs to be enable for the mod to work.';
1515
$txt['OYTE_autoEmbed'] = 'Enable the autoembed feature';
1616
$txt['OYTE_autoEmbed_sub'] = 'If enable, all valid and available links posted will be converted to embedded videos automatically. If disabled you will have to use the BBC tags to convert links to videos.';
17+
$txt['OYTE_min_screen_size'] = 'Minimum screen size for sizes settings';
18+
$txt['OYTE_min_screen_size_sub'] = 'Screens larger than this setting will apply the video\'s width and height, defaults to 768';
1719
$txt['OYTE_video_width'] = 'Video\'s width:';
1820
$txt['OYTE_video_width_sub'] = 'If empty it will take the default value: 480.';
1921
$txt['OYTE_video_height'] = 'Video\'s height:';

Themes/default/languages/OharaYTEmbed.english.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
/*
44
* @package Ohara Youtube Embed mod
5-
* @version 1.2.12
6-
* @author Jessica Gonzalez <suki@missallsunday.com>
7-
* @copyright Copyright (C) 2020 Jessica Gonzalez
5+
* @version 1.2.13
6+
* @author Michel Mendiola <suki@missallsunday.com>
7+
* @copyright Copyright (C) 2022 Michel Mendiola
88
* @license http://www.mozilla.org/MPL/ MPL 2.0
99
*/
1010

@@ -14,6 +14,8 @@
1414
$txt['OYTE_master_sub'] = 'This is the master setting, it needs to be enable for the mod to work.';
1515
$txt['OYTE_autoEmbed'] = 'Enable the autoembed feature';
1616
$txt['OYTE_autoEmbed_sub'] = 'If enable, all valid and available links posted will be converted to embedded videos automatically. If disabled you will have to use the BBC tags to convert links to videos.';
17+
$txt['OYTE_min_screen_size'] = 'Minimum screen size for sizes settings';
18+
$txt['OYTE_min_screen_size_sub'] = 'Screens larger than this setting will apply the video\'s width and height, defaults to 768';
1719
$txt['OYTE_video_width'] = 'Video\'s width:';
1820
$txt['OYTE_video_width_sub'] = 'If empty it will take the default value: 480.';
1921
$txt['OYTE_video_height'] = 'Video\'s height:';

Themes/default/languages/OharaYTEmbed.polish-utf8.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
$txt['OYTE_master_sub'] = 'To jest ustawienie główne, to ustawienie musi być włączone, żeby modyfikacja działała.';
1515
$txt['OYTE_autoEmbed'] = 'Włącz funkcję automatyczne wbudowanie';
1616
$txt['OYTE_autoEmbed_sub'] = 'Jeśli ta funkcja będzie włączona to wszystkie prawidłowe i dostępne linki, będą automatycznie przekonwertowane na wbudowane filmy. Jeśli ta funkcja będzie wyłączona, będziesz musiał użyć znaczników BBC, aby przekonwertować linki na wbudowane filmy.';
17+
$txt['OYTE_min_screen_size'] = 'Minimum screen size for sizes settings';
18+
$txt['OYTE_min_screen_size_sub'] = 'Screens larger than this setting will apply the video\'s width and height, defaults to 768';
1719
$txt['OYTE_video_width'] = 'Szerokość filmu:';
1820
$txt['OYTE_video_width_sub'] = 'Jeśli zostawisz 0, zostanie ustawiona domyślna szerokość: 480';
1921
$txt['OYTE_video_height'] = 'Wysokość filmu:';

Themes/default/languages/OharaYTEmbed.polish.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22

33
/*
44
* @package Ohara Youtube Embed mod
5-
* @version 1.2.12
6-
* @author Jessica Gonz�lez <suki@missallsunday.com>
7-
* @copyright Copyright (C) 2020 Jessica Gonz�lez
5+
* @version 1.2.13
6+
* @author Michel Mendiola <suki@missallsunday.com>
7+
* @copyright Copyright (C) 2022 Michel Mendiola
88
* @license http://www.mozilla.org/MPL/ MPL 2.0
99
*/
1010

1111
global $txt;
1212

13-
$txt['OYTE_master'] = 'W��cz modyfikacj� Ohara Youtube Embed';
14-
$txt['OYTE_master_sub'] = 'To jest ustawienie g��wne, to ustawienie musi by� w��czone, �eby modyfikacja dzia�a�a.';
15-
$txt['OYTE_autoEmbed'] = 'W��cz funkcj� automatyczne wbudowanie';
16-
$txt['OYTE_autoEmbed_sub'] = 'Je�li ta funkcja b�dzie w��czona to wszystkie prawid�owe i dost�pne linki, b�d� automatycznie przekonwertowane na wbudowane filmy. Je�li ta funkcja b�dzie wy��czona, b�dziesz musia� u�y� znacznik�w BBC, aby przekonwertowa� linki na wbudowane filmy.';
17-
$txt['OYTE_video_width'] = 'Szeroko�� filmu:';
18-
$txt['OYTE_video_width_sub'] = 'Je�li zostawisz 0, zostanie ustawiona domy�lna szeroko��: 480';
19-
$txt['OYTE_video_height'] = 'Wysoko�� filmu:';
20-
$txt['OYTE_video_height_sub'] = 'Je�li zostawisz 0, zostanie ustawiona domy�lna wysoko��: 270';
13+
$txt['OYTE_master'] = 'Włącz modyfikację Ohara Youtube Embed';
14+
$txt['OYTE_master_sub'] = 'To jest ustawienie główne, to ustawienie musi być włączone, żeby modyfikacja działała.';
15+
$txt['OYTE_autoEmbed'] = 'Włącz funkcję automatyczne wbudowanie';
16+
$txt['OYTE_autoEmbed_sub'] = 'Jeśli ta funkcja będzie włączona to wszystkie prawidłowe i dostępne linki, będą automatycznie przekonwertowane na wbudowane filmy. Jeśli ta funkcja będzie wyłączona, będziesz musiał użyć znaczników BBC, aby przekonwertować linki na wbudowane filmy.';
17+
$txt['OYTE_min_screen_size'] = 'Minimum screen size for sizes settings';
18+
$txt['OYTE_min_screen_size_sub'] = 'Screens larger than this setting will apply the video\'s width and height, defaults to 768';
19+
$txt['OYTE_video_width'] = 'Szerokość filmu:';
20+
$txt['OYTE_video_width_sub'] = 'Jeśli zostawisz 0, zostanie ustawiona domyślna szerokość: 480';
21+
$txt['OYTE_video_height'] = 'Wysokość filmu:';
22+
$txt['OYTE_video_height_sub'] = 'Jeśli zostawisz 0, zostanie ustawiona domyślna wysokość: 270';
2123
$txt['OYTE_desc'] = 'Wstaw link do filmu z youtube';
2224
$txt['OYTE_vimeo_desc'] = 'Wstaw link do filmu z vimeo';
2325
$txt['OYTE_gifv_desc'] = 'Wstaw link do gifa z imgur';
24-
$txt['OYTE_unvalid_link'] = 'Nieprawid�owy link %s';
26+
$txt['OYTE_unvalid_link'] = 'Nieprawidłowy link %s';
2527
$txt['OYTE_title'] = 'Modyfikacja Ohara Youtube|Vimeo Embed';

Themes/default/languages/OharaYTEmbed.spanish_es-utf8.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
$txt['OYTE_master_sub'] = 'Esta es la configuración principal, necesita estar activada para que el mod funcione correctamente.';
1515
$txt['OYTE_autoEmbed'] = 'Activar la opción "autoembed"';
1616
$txt['OYTE_autoEmbed_sub'] = 'Si se activa, todos los enlaces de videos válidos serán convertidos a videos automáticamente. Si se desactiva, tendrás que usar el tag "youtube" para mostrar el video.';
17+
$txt['OYTE_min_screen_size'] = 'Tamaño mínimo de pantalla para aplicar límite de anchura y altura';
18+
$txt['OYTE_min_screen_size_sub'] = 'En pantallas más grandes que este número se limitarán el ancho y la altura de los videos. Por defecto: 768';
1719
$txt['OYTE_video_width'] = 'Ancho del video:';
18-
$txt['OYTE_video_width_sub'] = 'Si se deja vacío se usará el valor por deault: 480.';
20+
$txt['OYTE_video_width_sub'] = 'Si se deja vacío se usará el valor por default: 480.';
1921
$txt['OYTE_video_height'] = 'Altura del video:';
2022
$txt['OYTE_video_height_sub'] = 'Si se deja vacío se usará el valor por defecto: 270';
2123
$txt['OYTE_desc'] = 'Inserta un video desde youtube';

Themes/default/languages/OharaYTEmbed.spanish_es.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
/*
44
* @package Ohara Youtube Embed mod
5-
* @version 1.2.12
6-
* @author Jessica Gonzalez <suki@missallsunday.com>
7-
* @copyright Copyright (C) 2020 Jessica Gonzalez
5+
* @version 1.2.13
6+
* @author Michel Mendiola <suki@missallsunday.com>
7+
* @copyright Copyright (C) 2022 Michel Mendiola
88
* @license http://www.mozilla.org/MPL/ MPL 2.0
99
*/
1010

@@ -14,8 +14,10 @@
1414
$txt['OYTE_master_sub'] = 'Esta es la configuraci&oacute;n principal, necesita estar activada para que el mod funcione correctamente.';
1515
$txt['OYTE_autoEmbed'] = 'Activar la opci&oacute;n "autoembed"';
1616
$txt['OYTE_autoEmbed_sub'] = 'Si se activa, todos los enlaces de videos v&aacute;lidos ser&aacute;n convertidos a videos autom&aacute;ticamente. Si se desactiva, tendr&aacute;s que usar el tag "youtube" para mostrar el video.';
17+
$txt['OYTE_min_screen_size'] = 'Tama&ntilde;o m&iacute;nimo de pantalla para aplicar l&iacute;mite de anchura y altura';
18+
$txt['OYTE_min_screen_size_sub'] = 'En pantallas m&aacute;s grandes que este n&uacute;mero se limitar&aacute;n el ancho y la altura de los videos. Por defecto: 768';
1719
$txt['OYTE_video_width'] = 'Ancho del video:';
18-
$txt['OYTE_video_width_sub'] = 'Si se deja vac&iacute;o se usar&aacute; el valor por deault: 480.';
20+
$txt['OYTE_video_width_sub'] = 'Si se deja vac&iacute;o se usar&aacute; el valor por default: 480.';
1921
$txt['OYTE_video_height'] = 'Altura del video:';
2022
$txt['OYTE_video_height_sub'] = 'Si se deja vac&iacute;o se usar&aacute; el valor por defecto: 270';
2123
$txt['OYTE_desc'] = 'Inserta un video desde youtube';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* @package Ohara Youtube Embed mod
5+
* @version 1.2.13
6+
* @author Jessica González <suki@missallsunday.com>
7+
* @copyright Copyright (C) 2020 Jessica González
8+
* @license http://www.mozilla.org/MPL/ MPL 2.0
9+
*/
10+
11+
global $txt;
12+
13+
$txt['OYTE_master'] = 'Activar el mod Ohara Youtube Embed';
14+
$txt['OYTE_master_sub'] = 'Esta es la configuración principal, necesita estar activada para que el mod funcione correctamente.';
15+
$txt['OYTE_autoEmbed'] = 'Activar la opción "autoembed"';
16+
$txt['OYTE_autoEmbed_sub'] = 'Si se activa, todos los enlaces de videos válidos serán convertidos a videos automáticamente. Si se desactiva, tendrás que usar el tag "youtube" para mostrar el video.';
17+
$txt['OYTE_min_screen_size'] = 'Tamaño mínimo de pantalla para aplicar límite de anchura y altura';
18+
$txt['OYTE_min_screen_size_sub'] = 'En pantallas más grandes que este número se limitarán el ancho y la altura de los videos. Por defecto: 768';
19+
$txt['OYTE_video_width'] = 'Ancho del video:';
20+
$txt['OYTE_video_width_sub'] = 'Si se deja vacío se usará el valor por default: 480.';
21+
$txt['OYTE_video_height'] = 'Altura del video:';
22+
$txt['OYTE_video_height_sub'] = 'Si se deja vacío se usará el valor por defecto: 270';
23+
$txt['OYTE_desc'] = 'Inserta un video desde youtube';
24+
$txt['OYTE_vimeo_desc'] = 'Inserta un video desde vimeo';
25+
$txt['OYTE_gifv_desc'] = 'Inserta un gifv de imgur';
26+
$txt['OYTE_unvalid_link'] = 'No es una dirección de %s válida';
27+
$txt['OYTE_title'] = 'Ohara Youtube|Vimeo Embed mod';

0 commit comments

Comments
 (0)