• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Missing background image for YouTube Videos

Started by Hersh,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HershTopic starter

This is something which I noticed with a recent update. YouTube videos which are not HD do not include 'maxresdefault.jpg' image. The highest quality is 'hqdefault.jpg.' For this reason, many lower quality videos show this background image in JW Player, which makes it seem like the video has been removed:


To fix this without losing the option of using maxresdefault.jpg when available, you will need to edit class.providers.php

Find:
                        $real_link = 'http://www.youtube.com/watch?v=' . $videoId;
                        $img = 'http://i1.ytimg.com/vi/' . $videoId . '/`maxresdefault.jpg';
                        $embedCode = $this->_jwplayer($real_link, $img, thumb_fix(get_option('player-logo')));
                    }

REPLACE with:
                        $real_link = 'http://www.youtube.com/watch?v=' . $videoId;
                        $md5image1 = md5_file('http://i1.ytimg.com/vi/' . $videoId . '/maxresdefault.jpg');
                        $md5image2 = md5_file('http://i4.ytimg.com/vi/0/0.jpg');
                        if ($md5image1 == $md5image2) {
                            $img = 'http://i1.ytimg.com/vi/' . $videoId . '/hqdefault.jpg';
                        } else {
                            $img = 'http://i1.ytimg.com/vi/' . $videoId . '/maxresdefault.jpg';
                        }


Note, this might reduce page load time.

If you don't want the slight performance reduction for non-cached pages, you can simply just change this:
$img = 'http://i1.ytimg.com/vi/' . $videoId . '/`maxresdefault.jpg';

To this:
$img = 'http://i1.ytimg.com/vi/' . $videoId . '/`hqdefault.jpg';
  •  

Similar topics (7)