• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] How to add default thumbnails to videos with unavailable thumbnails.

Started by gaunt93,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gaunt93Topic starter

I play most of my videos remotely, and sometimes a see a broken link for the thumbnail image. I was wondering if there was a way to add a default image to fill that space. Thanks!
  •  

PHPVibe A.


gaunt93Topic starter

Awesome thanks for the idea. It was .video-thumb, but now I need to get rid of the broken link the webpage is trying to load.
  •  

PHPVibe A.

Here is an function to use somewhere:

function checkRemoteFile($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    // don't download content
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if(curl_exec($ch)!==FALSE)
    {
        return true;
    }
    else
    {
        return false;
    }
	
}


It will return false if the file no longer exists, and you can use an unpublish for it.
Not delete, as you may want to manually check it to.

gaunt93Topic starter

Awesome. I'll look into using it. But this is what I did to replace a broken img link.


tpl\main\video-loop.php:
<div id="video-'.$video->id.'" class="video">
<div class="video-thumb">
		<a class="clip-link" data-id="'.$video->id.'" title="'.$full_title.'" href="'.$url.'">
			<span class="clip">
				<img src="'.thumb_fix($video->thumb, true, get_option('thumb-width'), get_option('thumb-height')).'" alt="'.$full_title.'"/><span class="vertical-align"></span>
			</span>
          	<span class="overlay"></span>
		</a>';


to this
<div id="video-'.$video->id.'" class="video">
<div class="video-thumb">
		<a class="clip-link" data-id="'.$video->id.'" title="'.$full_title.'" href="'.$url.'">
			<span class="clip">
				<img src="'.thumb_fix($video->thumb, true, get_option('thumb-width'), get_option('thumb-height')).'" alt="'.$full_title.'" onerror="this.src=\'../../uploads/favicon300x300.png\'; this.id=\'img_thumb\'"/><span class="vertical-align"></span>
			</span>
          	<span class="overlay"></span>
		</a>';


I will look into using the code you gave me, and ill post back here if i come up with something.
  •  

PHPVibe A.

Hey, don't use it in a loop (the check function for remote), mainly in com_com_video.php I would use it, to check it on access, cause on loop it's overkill.

Similar topics (7)