I am not using YouTube links in my projects. But as there hasn't been any help from others for a while, I have taken the time and added a YouTube-video-link field to one of my tables.
Configuration

- AppGini_x13FE1CsAZ.png (18.86 KiB) Viewed 5229 times
First of all, there are different meanings of "video size". So just for clarification:
- The size of the video (for example 5MB)?
- The display size of the thumbnail in Table View rows
- The display size of the thumbnail in Detail View
1. Video size
As AppGini only stores a link to a video, stored in YouTube, I think we cannot adjust the video-size. Only the creator can by uploading a reduced video.
2. Table View
In my test it works as expected. Thumbnail configures as 80x80. AppGini resizes the thumbnail, keeping the aspect ration. The resulting image is 80x60.

- chrome_HCZNqDZtL4.png (17.12 KiB) Viewed 5229 times
3. Detail View
Now it becomes a bit more complicated: In
TABLENAME_dml.php
file the template-placeholder
<%%YOUTUBE(FIELDNAME)%%>
gets replaced, calling the function
get_embed
. Here we still have the correct size-settings, given in field-configuration. The placeholder gets replaced by the return value of
get_embed('youtube', $urow['video'], '480', '360')
. I've just tested that function call. It returns a complete
<iframe .../>
-tag including width/height dimensions. Those dimensions do NOT match with our given configuration:

- chrome_Yx3yYTuBq8.png (5.89 KiB) Viewed 5229 times
To me, it looks like YouTube automatically returns these dimensions no matter what we pass. But honestly, I don't know much about it. So I manually ran the request that AppGini makes to YouTube:
Code: Select all
https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=JRbHMSrK-bw&ab_channel=DreamTheater&maxwidth=480&maxheight=360

- chrome_ucfUHVXVCh.png (25.76 KiB) Viewed 5229 times
And also here (which represents the HTML code to be rendered):

- chrome_ym9PzlJTf8.png (7.83 KiB) Viewed 5229 times
In browser, the JSON response looks quite good. So, why don't we get those dimensions in our final
<iframe>
HTML code afterwards?
More testing required. I've noticed, when requesting from youtube in the browser (address-bar) the returned JSON looks correct. But when testing the request in code, I receive different size:
I've extracted fragments of actual code for simulatinh AppGini's request and for narrowing down the problem:
Code: Select all
<!-- file: hooks/footer-extras.php -->
<pre>
<?php
$urow = getRecord("instructions", 1);
$url = $urow["video"];
$provider = "youtube";
$providers = [
'youtube' => ['oembed' => 'https://www.youtube.com/oembed?'],
];
$max_width = 480;
$max_height = 360;
$oembed = $providers[$provider]['oembed'] . 'url=' . urlencode($url) . "&maxwidth={$max_width}&maxheight={$max_height}&format=json";
$data_json = request_cache($oembed, true);
var_dump($data_json);
?>
</pre>
Code: Select all
string(823) "{"title":"Dream Theater - Metropolis Pt.2 Encore (from Breaking The Fourth Wall)","author_name":"Dream Theater","author_url":"https://www.youtube.com/@dreamtheaterofficial","type":"video","height":113,"width":200,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/JRbHMSrK-bw/hqdefault.jpg","html":"\u003ciframe width=\u0022200\u0022 height=\u0022113\u0022 src=\u0022https://www.youtube.com/embed/JRbHMSrK-bw?feature=oembed\u0022 frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\u0022 allowfullscreen title=\u0022Dream Theater - Metropolis Pt.2 Encore (from Breaking The Fourth Wall)\u0022\u003e\u003c/iframe\u003e"}"
Those values are different from the given dimensions, but those match up with the final
<iframe>
-dimensions.
I cannot say why youtube returns the correct size when being called via browser-address-bar, but returns a different size when being called via code. It may have to do with HTTP Header information, passed from client to server, but, actually, I do not know in detail. I hope one of our AppGini Super Heroes will jump in and continue my work at this point.
It figured out, after some Googling, there are many developers out there, having similar problems. So it seems to be a common YouTube problem.
Gonna try out a few hacks the next hours.