Retrieve 16:9 youtube thumbnails instead of the 4:3 black bordered ones?

STiGYFishh

I'm trying to use PHP to retrieve a list of recent uploaded videos from a Youtube channel however the thumbnails are all in 4:3 format with black borders at the top and bottom. I am using the following to retrieve the thumbnails:

$thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;

and this to import them:

<img src="<?php echo $thumbnail;?>"/>

The youtube API website and various other Q&A websites say you can use the variable

yt:name='mqdefault'

to retrieve the 16:9 thumbnails with no borders, however I have no clue where to incorporate this into the PHP?

dxritchie
http://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg

You would need you url to look similar to one of those. Not sure what: (string)$media->group->thumbnail[0]->attributes()->url; is returning but I would take a look at that URL and make sure it resembles something similar to above.

For you below example you want you URL to resemble this.

http://img.youtube.com/vi/0GQPoyMr30o/mqdefault.jpg
http://img.youtube.com/vi/0GQPoyMr30o/maxresdefault.jpg

Try doing something like this:

<?php 
$thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
$thumbnail = str_replace('0.jpg', 'mqdefault.jpg', $thumbnail);
?>

<img src="<?php echo $thumbnail; ?>" />

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Youtube API Actionscript 3 and Thumbnails

From Dev

Why is the display resolution not exactly 16:9 or 4:3?

From Dev

JWPlayer aspect ratio keeps 4:3 for my 16:9 video

From Dev

Error 500 Adding Thumbnails with Youtube API v3

From Dev

Styling thumbnails with bootstrap 3 and rails 4

From Dev

can't get 16:9 ratio on kvm, only 16:10 or 4:3

From Dev

Partially bordered table of Bootstrap 3

From Dev

No thumbnails are returned in youtube api

From Dev

Class getting bordered instead of its element

From Dev

Add black bars to create a 16x9 image

From Dev

JAVA CRC16 function returns a 3 characters response instead of 4

From Dev

How to change a LibreOffice Impress presentation from 4:3 to 16:9 ratio?

From Dev

How can I crop a 16:9 video to 4:3, cutting off the edges?

From Dev

How to change a LibreOffice Impress presentation from 4:3 to 16:9 ratio?

From Dev

LibreOffice Impress: change screen format from 4:3 to 16:9 without stretching images?

From Dev

How to change a LibreOffice Impress presentation from 4:3 to 16:9 ratio for version 6?

From Dev

Cropping videos to perfectly fit YouTube 16:9 dimensions with PiTiVi or Kdenlive?

From Dev

Logical CPU count return 16 instead of 4

From Dev

Why use 1<<4 instead of 16?

From Dev

Firefox not displaying thumbnails for YouTube and eBay

From Dev

Need to have 4 results show up on one out-gridview instead of 4 separate ones

From Dev

regex to match 3-digit numbers but not 4-digit ones

From Dev

If display(15) i want the result 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24

From Dev

Retrieve number of items in playlist with YouTube API v3

From Dev

Retrieve Video IDs contained in a Playlist - YouTube API v3

From Dev

iOS Youtube API v3 retrieve my channels

From Dev

Why does my ASP.NET MVC 4 application create new entities instead of updating the old ones?

From Dev

Black borders in Ubuntu 16

From Dev

Imagemagick - replace transparent pixel by black ones

Related Related

  1. 1

    Youtube API Actionscript 3 and Thumbnails

  2. 2

    Why is the display resolution not exactly 16:9 or 4:3?

  3. 3

    JWPlayer aspect ratio keeps 4:3 for my 16:9 video

  4. 4

    Error 500 Adding Thumbnails with Youtube API v3

  5. 5

    Styling thumbnails with bootstrap 3 and rails 4

  6. 6

    can't get 16:9 ratio on kvm, only 16:10 or 4:3

  7. 7

    Partially bordered table of Bootstrap 3

  8. 8

    No thumbnails are returned in youtube api

  9. 9

    Class getting bordered instead of its element

  10. 10

    Add black bars to create a 16x9 image

  11. 11

    JAVA CRC16 function returns a 3 characters response instead of 4

  12. 12

    How to change a LibreOffice Impress presentation from 4:3 to 16:9 ratio?

  13. 13

    How can I crop a 16:9 video to 4:3, cutting off the edges?

  14. 14

    How to change a LibreOffice Impress presentation from 4:3 to 16:9 ratio?

  15. 15

    LibreOffice Impress: change screen format from 4:3 to 16:9 without stretching images?

  16. 16

    How to change a LibreOffice Impress presentation from 4:3 to 16:9 ratio for version 6?

  17. 17

    Cropping videos to perfectly fit YouTube 16:9 dimensions with PiTiVi or Kdenlive?

  18. 18

    Logical CPU count return 16 instead of 4

  19. 19

    Why use 1<<4 instead of 16?

  20. 20

    Firefox not displaying thumbnails for YouTube and eBay

  21. 21

    Need to have 4 results show up on one out-gridview instead of 4 separate ones

  22. 22

    regex to match 3-digit numbers but not 4-digit ones

  23. 23

    If display(15) i want the result 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24

  24. 24

    Retrieve number of items in playlist with YouTube API v3

  25. 25

    Retrieve Video IDs contained in a Playlist - YouTube API v3

  26. 26

    iOS Youtube API v3 retrieve my channels

  27. 27

    Why does my ASP.NET MVC 4 application create new entities instead of updating the old ones?

  28. 28

    Black borders in Ubuntu 16

  29. 29

    Imagemagick - replace transparent pixel by black ones

HotTag

Archive