Related Topics


[Video CMS v4]How to add default thumbnails to videos with unavailable thumbnails.  (Read 1062 times) Print

1 B


gaunt93  April 26, 2014, 06:16:27 AM

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!

Logged


Alexander  April 27, 2014, 12:05:03 AM

Hi! Set an image background to .video in css?

Logged

gaunt93  April 27, 2014, 12:53:53 AM

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.

Logged


Alexander  April 27, 2014, 01:05:17 AM

Here is an function to use somewhere:

Code
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.

Logged

gaunt93  April 27, 2014, 01:44:50 AM

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


tpl\main\video-loop.php:
Code
<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
Code
<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.

Logged


Alexander  April 27, 2014, 04:01:43 PM

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.

Logged