<?php
function serpentsoft_return_correct_img_size($size = 'large'){
    $output = '';
    $page_layout = serpentsoft_get_data('serpentsoft_pagelayout');
    if( $page_layout == '2cols-left' || $page_layout == '2cols-right' ){
        switch ($size){
            case 'large':
                $output = 'serpentsoft_704';
            break;
            case 'medium':
                $output = 'serpentsoft_343';
            break;
            case 'small':
                $output = 'serpentsoft_100';
            break;
            default :
                $output = 'serpentsoft_704';
            break;
        }
    }
    else{
        switch ($size){
            case 'large':
                $output = 'serpentsoft_604';
            break;
            case 'medium':
                $output = 'serpentsoft_310';
            break;
            case 'small':
                $output = 'serpentsoft_100';
            break;
            default :
                $output = 'serpentsoft_604';
            break;
        }
    }
    
    if(!empty($output)) { return $output; }
}

function serpentsoft_grab_post_banner_figure($id = '', $array_args = '', $img_size = 'medium') {
    $post_type = 'serpentsoft_post_format';
    $video_provider = 'serpentsoft_video_provider';
    $video_code = 'serpentsoft_video_url_code';

    $post_id = '';
    $post_desc = '';

    if ($id == '') {
        global $post;
        $post_id = $post->ID;
    } else {
        global $post;
        $post_id = $id;
    }

    $get_meta = get_post_custom($post_id);

    if (isset($get_meta[$post_type][0]) && $get_meta[$post_type][0]):
        $postTypeControl = $get_meta[$post_type][0];

        switch ($postTypeControl) {
            case 'image': {
                    // without checking (id)
                    serpentsoft_post_featured_image($img_size, $post_id, $array_args);
                }
                break;

            case 'video': {
                    $videoProviderControl = $get_meta[$video_provider][0];
                    $videoCode = get_post_meta($post_id, $video_code, true);

                    if (function_exists("has_post_thumbnail") && has_post_thumbnail($post_id)) {
                        $grab_args = '';

                        if ($array_args):
                            foreach ($array_args as $key => $value) {
                                $grab_args .= ' ' . $key . '="' . $value . '" ';
                            }
                        endif;

                        $img_src = '';

                        switch ($img_size) {
                            case 'large':
                                $img_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), serpentsoft_return_correct_img_size('large') );
                                break;

                            case 'medium':
                                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), serpentsoft_return_correct_img_size('medium') );
                                break;

                            case 'small':
                                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'serpentsoft_100');
                                break;

                            default:
                                $img_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), serpentsoft_return_correct_img_size('large') );
                                break;
                        }

                        if (is_array($img_src)) {
                            echo '<img src="' . $img_src[0] . '" ' . $grab_args . ' alt="' . $post_desc . '" />';
                        }
                    }

                    //if ( has_post_thumbnail($post_id) ){ 
                    //the_post_thumbnail('post-thumbnail', $array_args);
                    //}
                    // echo '<img src="' . serpentsoft_post_image_get_first('large', $post_id) . '"' . $array_args . ' />';
                    else {
                        $img_args = '';
                        if (is_array($array_args)) {
                            foreach ($array_args as $key => $value) {
                                $img_args .= ' ' . $key . '="' . $value . '" ';
                            }
                        }

                        switch ($videoProviderControl) {
                            case 'youtube':
                            case 'youtu': {
                                    if ($img_size == 'large') {
                                        echo '<img src="' . 'http://img.youtube.com/vi/' . $videoCode . '/0.jpg" ' . $img_args . ' />';
                                    } else {
                                        echo '<img src="' . 'http://img.youtube.com/vi/' . $videoCode . '/1.jpg" ' . $img_args . ' />';
                                    }
                                }
                                break;

                            case 'vimeo': {
                                    /* $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/" . $videoCode . ".php")); */

                                    $hash = wp_remote_get("http://vimeo.com/api/v2/video/" . $videoCode . ".php");
                                    $thumb = unserialize(wp_remote_retrieve_body($hash));

                                    if ($img_size == 'large') {
                                        echo '<img src="' . $thumb['0']['thumbnail_large'] . '" ' . $img_args . ' />';
                                    } elseif ($img_size == 'medium') {
                                        echo '<img src="' . $thumb['0']['thumbnail_medium'] . '" ' . $img_args . ' />';
                                    } elseif ($img_size == 'small') {
                                        echo '<img src="' . $thumb['0']['thumbnail_small'] . '" ' . $img_args . ' />';
                                    } else {
                                        echo '<img src="' . $thumb['0']['thumbnail_large'] . '" ' . $img_args . ' />';
                                    }
                                }
                                break;

                            case 'dailymotion': {
                                    /* Return (320 x 240) px
                                      $hash = json_decode( "https://api.dailymotion.com/video/" . $videoCode . "?fields=thumbnail_large_url" )); */
                                    echo '<img src="' . 'http://www.dailymotion.com/thumbnail/video/' . $videoCode . '" ' . $img_args . ' />';
                                }
                                break;

                            default: {
                                    serpentsoft_post_featured_image($img_size, $id, $array_args);
                                }
                                break;
                        }
                    }
                }
                break;

            default: {
                    serpentsoft_post_featured_image($img_size, $id, $array_args);
                }
                break;
        }

    else:
        serpentsoft_post_featured_image($img_size, $id, $array_args);
    endif;
}

// Get Large (604x345 px) image
function serpentsoft_default_image() {
    if (serpentsoft_get_data('serpentsoft_upload_post_default_image')) {
        return serpentsoft_get_data('serpentsoft_upload_post_default_image');
    } else {
        return get_template_directory_uri() . '/images/post-default.png';
    }
}

// Get Medium (294x190 px) image
function serpentsoft_default_image_for_medium_cat() {
    if (serpentsoft_get_data('serpentsoft_upload_def_img_horiz_ver_cat')) {
        return serpentsoft_get_data('serpentsoft_upload_def_img_horiz_ver_cat');
    } elseif (serpentsoft_get_data('serpentsoft_upload_post_default_image')) {
        return serpentsoft_get_data('serpentsoft_upload_post_default_image');
    } else {
        // Get Large Image
        return get_template_directory_uri() . '/images/post-default.png';
    }
}

// Get Small (80x75 px) image
function serpentsoft_default_image_for_small_cat() {
    /* if( serpentsoft_get_data('serpentsoft_upload_def_img_small_cat') ) {
      return serpentsoft_get_data('serpentsoft_upload_def_img_small_cat');
      } */
    if (serpentsoft_get_data('serpentsoft_upload_def_img_horiz_ver_cat')) {
        return serpentsoft_get_data('serpentsoft_upload_def_img_horiz_ver_cat');
    } elseif (serpentsoft_get_data('serpentsoft_upload_post_default_image')) {
        return serpentsoft_get_data('serpentsoft_upload_post_default_image');
    } else {
        // Get Large Image
        return get_template_directory_uri() . '/images/post-default.png';
    }
}

// Get First Image of the post if exist, else get default image
function serpentsoft_post_image_get_first($i_size = '', $id = '') {
    if ($id == '') {
        global $post, $posts;
        $post_id = $post->ID;
        $content = $post->post_content;
    } else {
        global $post, $posts;
        $post_id = $id;
        $content_post = get_post($post_id);
        $content = $content_post->post_content;
    }

    $first_img = '';

    ob_start();
    ob_end_clean();

    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);

    if (isset($matches[1][0]) && !empty($matches[1][0])) {
        $first_img = $matches [1][0];
    } else {
        switch ($i_size) {
            case 'post': {
                    $first_img = serpentsoft_default_image();
                }
                break;

            case 'large': {
                    $first_img = serpentsoft_default_image();
                }
                break;

            case 'medium': {
                    $first_img = serpentsoft_default_image_for_medium_cat();
                }
                break;

            case 'small': {
                    $first_img = serpentsoft_default_image_for_small_cat();
                }
                break;
        }
    }
    return $first_img;
}

function serpentsoft_post_featured_image($i_size = 'large', $id = '', $array_args = '') {
    if ($id == '') {
        global $post;
        $post_id = $post->ID;
    } else {
        global $post;
        $post_id = $id;
    }

    $post_desc = htmlspecialchars(get_post($post_id)->post_title);

    if (function_exists("has_post_thumbnail") && has_post_thumbnail($post_id)) {
        //the_post_thumbnail('post-thumbnail', $array_args); //array('itemprop' => 'contentURL'));
        $grab_args = '';

        if ($array_args):
            foreach ($array_args as $key => $value) {
                $grab_args .= $key . '="' . $value . '" ';
            }
        endif;

        $img_src = '';

        switch ($i_size) {
            case 'large':
                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), serpentsoft_return_correct_img_size('large') );
                break;

            case 'medium':
                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), serpentsoft_return_correct_img_size('medium') );
                break;

            case 'small':
                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'serpentsoft_100');
                break;

            default:
                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), serpentsoft_return_correct_img_size('large') );
                break;
        }

        if (is_array($img_src)) {
            echo '<img src="' . $img_src[0] . '" ' . $grab_args . 'alt="' . $post_desc . '" />';
        }
    } else {
        $grab_args = '';
        if ($array_args):
            foreach ($array_args as $key => $value) {
                $grab_args .= ' ' . $key . '="' . $value . '" ';
            }
        endif;

        switch ($i_size) {
            case 'post':
                // if single or page have no image
                //echo '<img src="' . serpentsoft_post_image_get_first('post', $post_id) . '"' . $grab_args . 'alt="' . $post_desc . '" />';
                break;

            case 'large':
                echo '<img src="' . serpentsoft_post_image_get_first('large', $post_id) . '" ' . $grab_args . 'alt="' . $post_desc . '" />';
                break;

            case 'medium':
                echo '<img src="' . serpentsoft_post_image_get_first('medium', $post_id) . '" ' . $grab_args . 'alt="' . $post_desc . '" />';
                break;

            case 'small':
                echo '<img src="' . serpentsoft_post_image_get_first('small', $post_id) . '" ' . $grab_args . 'alt="' . $post_desc . '" />';
                break;
        }
    }
}

/* function serpentsoft_post_featured_image_medium($id = '', $array_args = ''){

  }

  function serpentsoft_post_featured_image_for_small_cats($id = ''){

  }

  function serpentsoft_post_image($id = '', $array_args = ''){

  } */

/* for single and page only large images */

function serpentsoft_post_banner_show() {

    global $post;
    $get_meta = get_post_custom($post->ID);
    $img_post = '';

    if (isset($get_meta['serpentsoft_post_format'][0]) && $get_meta['serpentsoft_post_format'][0] != '') :

        $cur_banner = $get_meta['serpentsoft_post_format'][0];

        switch ($cur_banner) {

            case 'default': {
                
            }
            break;
        
            case 'image': { ?>
                    <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">

                    <?php if ( isset($get_meta['serpentsoft_lightbox_check']) && $get_meta['serpentsoft_lightbox_check'] ) {
                        if (function_exists("has_post_thumbnail") && has_post_thumbnail($post->ID)) {
                            //$img_src = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
                            $img_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), serpentsoft_return_correct_img_size('large') );

                            if (is_array($img_src)) {
                                echo '<a href="' . $img_src[0] . '" rel="prettyPhoto"><img class="thumb_video_lightbox" src="' . $img_src[0] . '" itemprop="contentURL"' . ' alt="' . the_title_attribute('echo=0') . '" /></a>';
                            }
                        } ?>

                        <?php } else {
                            $img_post = serpentsoft_post_featured_image('post', $post->ID, array('itemprop' => 'contentURL'));
                        }

                        if ($img_post != '') {
                            $xpath = new DOMXPath(@DOMDocument::loadHTML($img_post));
                            $src = $xpath->evaluate("string(//img/@src)");
                        } ?>

                        <?php //$img_post; ?>

                        <figcaption itemprop="description">
                    <?php $img_desc = get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?>
                            <?php
                            if (isset($img_desc) && !empty($img_desc)) {
                                echo $img_desc;
                            } else {
                                //echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true);
                                echo get_post(get_post_thumbnail_id())->post_excerpt;
                            }
                            ?>
                        </figcaption>
                    </figure>
                <?php } break;

            case 'video': {
                    ?>
                    <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/VideoObject">

                        <?php
                        switch ($get_meta['serpentsoft_video_provider'][0]) {
                            case 'youtube': {
                                    $vidYouTube_code = get_post_meta($post->ID, 'serpentsoft_video_url_code', true);
                                    if ( isset($get_meta['serpentsoft_lightbox_check']) && $get_meta['serpentsoft_lightbox_check'] ):
                                        ?>

                                        <a rel="prettyPhoto" href="http://youtu.be/<?php echo $vidYouTube_code; ?>"><img class="thumb_video_lightbox" src="http://img.youtube.com/vi/<?php echo $vidYouTube_code . '/0.jpg'; ?>" /></a>
                                    <?php else: ?>
                                        <iframe class="youtube-player" type="text/html" src="http://www.youtube.com/embed/<?php echo $vidYouTube_code; ?>?wmode=transparent&amp;wmode=opaque" allowfullscreen webkitAllowFullScreen mozallowfullscreen frameborder="0"></iframe>
                                    <?php endif; ?>
                                <?php
                                } break;

                            case 'vimeo': {
                                    $vidVimeo_code = get_post_meta($post->ID, 'serpentsoft_video_url_code', true);
                                    if ( isset($get_meta['serpentsoft_lightbox_check']) && $get_meta['serpentsoft_lightbox_check'] ):
                                        $hash = wp_remote_get("http://vimeo.com/api/v2/video/" . $vidVimeo_code . ".php");
                                        $thumb = unserialize(wp_remote_retrieve_body($hash));
                                        ?>
                                        <a rel="prettyPhoto" href="http://vimeo.com/<?php echo $vidVimeo_code; ?>"><img class="thumb_video_lightbox" src="<?php echo $thumb['0']['thumbnail_large']; ?>" /></a>

                                    <?php else: ?>
                                        <iframe src="http://player.vimeo.com/video/<?php echo $vidVimeo_code; ?>?title=0&amp;byline=0&amp;portrait=0&amp;wmode=transparent&amp;wmode=opaque" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
                                    <?php endif; ?>

                            <?php
                            } break;

                        case 'dailymotion': {
                                $vidDailyMotion_code = get_post_meta($post->ID, 'serpentsoft_video_url_code', true);
                                if ( isset($get_meta['serpentsoft_lightbox_check']) && $get_meta['serpentsoft_lightbox_check'] ):
                                    ?>
                                        <a rel="prettyPhoto" href="http://www.dailymotion.com/video/<?php echo $vidDailyMotion_code; ?>"><img class="thumb_video_lightbox" src="http://www.dailymotion.com/thumbnail/video/<?php echo $vidDailyMotion_code; ?>" /></a>

                                    <?php else: ?>
                                        <iframe frameborder="0" src="http://www.dailymotion.com/embed/video/<?php echo $vidDailyMotion_code; ?>"></iframe>
                                        <?php endif; ?>
                                    <?php
                                    } break;

                                case 'embedcode': {
                                        echo htmlspecialchars_decode(get_post_meta($post->ID, 'serpentsoft_video_embed_code', true));
                                    } break;
                            }
                            ?>

                        <figcaption itemprop="caption">
                        <?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?>
                        </figcaption>
                    </figure>

                <?php } break;

            case 'soundcloud': {
                    ?>
                    <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/AudioObject">

                        <?php
                        $url_soundcloud = htmlspecialchars_decode(get_post_meta($post->ID, 'serpentsoft_soundcloud_url', true));
                        echo serpentsoft_soundcloud($url_soundcloud, get_post_meta($post->ID, 'serpentsoft_soundcloud_autoplay', true), get_post_meta($post->ID, 'serpentsoft_soundcloud_artwork', true));
                        ?>

                        <figcaption itemprop="caption"><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></figcaption>
                    </figure>
                <?php } break;

            case 'map': {
                    ?>
                    <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
                    <?php $url_googlemap = htmlspecialchars_decode(get_post_meta($post->ID, 'serpentsoft_googlemap_url', true));
                    echo serpentsoft_googlemap($url_googlemap);
                    ?>

                        <figcaption itemprop="description"><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></figcaption>
                    </figure>
                <?php } break;

            case 'quotation': {
                    ?>
                    <figure class="featured-post-figure quotation" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
                        <hgroup>
                            <h3><?php echo get_post_meta($post->ID, 'serpentsoft_quote_text', true); ?></h3>
                            <h4><?php echo get_post_meta($post->ID, 'serpentsoft_quote_author', true); ?></h4>
                        </hgroup>

                        <figcaption itemprop="description"><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></figcaption>
                    </figure>
                <?php } break;

            case 'selfaudio': {
                    ?>
                    <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/AudioObject">

                        <div id="player_audio_<?php echo $post->ID; ?>" class="jp-jplayer"></div>
                        <div itemprop="contentURL" id="jp_container_1" class="jp-audio">
                            <div class="jp-type-single">
                                <div class="jp-gui jp-interface">
                                    <ul class="jp-controls">
                                        <!-- comment out any of the following <li>s to remove these buttons -->
                                        <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
                                        <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
                                        <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
                                        <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
                                        <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
                                        <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
                                    </ul>
                                    <!-- you can comment out any of the following divs too -->
                                    <div class="jp-progress">
                                        <div class="jp-seek-bar">
                                            <div class="jp-play-bar"></div>
                                        </div>
                                    </div>

                                    <div class="jp-volume-bar">
                                        <div class="jp-volume-bar-value"></div>
                                    </div>

                                    <div class="jp-current-time"></div>
                                    <div class="jp-duration"></div>
                                </div>
                                <div class="jp-title">
                                    <ul>
                                        <li><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></li>
                                    </ul>
                                </div>
                                <div class="jp-no-solution">
                                    <span>Update Required</span>
                                    To play the media you will need to either update your browser to a recent version or update your <a href="<?php echo 'http://get.adobe.com/flashplayer/'; ?>" target="_blank">Flash plugin</a>.
                                </div>
                            </div>
                        </div>

                        <figcaption itemprop="caption"><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></figcaption>

                        <script type="text/javascript">
                            //<![CDATA[
                            jQuery(document).ready(function() {
                                "use strict";
                                var jPlayerSWF = "<?php echo get_template_directory_uri() . '/framework/jPlayer-220'; ?>";
                                var urlMP3;
                                var urlOGA;
                                var urlM4A;

                    <?php if (get_post_meta($post->ID, 'serpentsoft_self_audio_mp3_url', true)): ?>
                                    urlMP3 = "<?php echo get_post_meta($post->ID, 'serpentsoft_self_audio_mp3_url', true); ?>";
                    <?php endif;
                    if (get_post_meta($post->ID, 'serpentsoft_self_audio_oga_url', true)):
                        ?>
                                    urlOGA = "<?php echo get_post_meta($post->ID, 'serpentsoft_self_audio_oga_url', true); ?>";
                    <?php endif;
                    if (get_post_meta($post->ID, 'serpentsoft_self_audio_m4a_url', true)):
                        ?>
                                    urlM4A = "<?php echo get_post_meta($post->ID, 'serpentsoft_self_audio_m4a_url', true); ?>";
                    <?php endif; ?>

                                jPlayerAudio('player_audio_<?php echo $post->ID; ?>', urlMP3, urlOGA, urlM4A, jPlayerSWF);

                            });
                            //]]>
                        </script>
                    </figure>
                <?php } break;

            case 'selfvideo': {
                    ?>
                    <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/VideoObject">

                        <div id="player_video_<?php echo $post->ID; ?>" class="jp-jplayer"></div>

                        <div itemprop="contentURL" id="jp_container_1" class="jp-video jp-video-360p">
                            <div class="jp-type-single">


                                <div class="jp-gui" style="">
                                    <div class="jp-video-play" style="display: block;">
                                        <a href="javascript:;" class="jp-video-play-icon" tabindex="1">play</a>
                                    </div>
                                    <div class="jp-interface">
                                        <div class="jp-progress">
                                            <div class="jp-seek-bar" style="width: 100%;">
                                                <div class="jp-play-bar" style="width: 0%;"></div>
                                            </div>
                                        </div>
                                        <div class="jp-current-time"></div>
                                        <div class="jp-duration"></div>
                                        <div class="jp-title">
                                            <ul>
                                                <li><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></li>
                                            </ul>
                                        </div>
                                        <div class="jp-controls-holder">
                                            <ul class="jp-controls">
                                                <li><a href="javascript:;" class="jp-play" tabindex="1" style="">play</a></li>
                                                <li><a href="javascript:;" class="jp-pause" tabindex="1" style="display: none;">pause</a></li>
                                                <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
                                                <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute" style="">mute</a></li>
                                                <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute" style="display: none;">unmute</a></li>
                                                <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume" style="">max volume</a></li>
                                            </ul>
                                            <div class="jp-volume-bar" style="">
                                                <div class="jp-volume-bar-value" style="width: 80%;"></div>
                                            </div>

                                            <ul class="jp-toggles">
                                                <li><a href="javascript:;" class="jp-full-screen" tabindex="1" title="full screen" style="">full screen</a></li>
                                                <li><a href="javascript:;" class="jp-restore-screen" tabindex="1" title="restore screen" style="display: none;">restore screen</a></li>
                                                <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat" style="">repeat</a></li>
                                                <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off" style="display: none;">repeat off</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <div class="jp-no-solution" style="display: none;">
                                    <span>Update Required</span>
                                    To play the media you will need to either update your browser to a recent version or update your <a href="<?php echo 'http://get.adobe.com/flashplayer/'; ?>" target="_blank">Flash plugin</a>.
                                </div>
                            </div>
                        </div>

                        <figcaption itemprop="caption"><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></figcaption>

                        <script type="text/javascript">
                            //<![CDATA[
                            jQuery(document).ready(function() {
                                "use strict";
                                jQuery("#player_video_<?php echo $post->ID; ?>").jPlayer({
                                    ready: function() {
                                        jQuery(this).jPlayer("setMedia", {
                    <?php
                    if (get_post_meta($post->ID, 'serpentsoft_self_video_m4v_url', true)):
                        echo 'm4v: "' . get_post_meta($post->ID, 'serpentsoft_self_video_m4v_url', true) . '",';
                    endif;
                    if (get_post_meta($post->ID, 'serpentsoft_self_video_ogv_url', true)):
                        echo 'ogv: "' . get_post_meta($post->ID, 'serpentsoft_self_video_ogv_url', true) . '",';
                    endif;
                    if (get_post_meta($post->ID, 'serpentsoft_self_video_webmv_url', true)):
                        echo 'webmv: "' . get_post_meta($post->ID, 'serpentsoft_self_video_webmv_url', true) . '",';
                    endif;
                    if (get_post_meta($post->ID, 'serpentsoft_self_video_poster_url', true)):
                        echo 'poster: "' . get_post_meta($post->ID, 'serpentsoft_self_video_poster_url', true) . '"';
                    endif;
                    ?>});
                                    },
                                    supplied: "webmv, ogv, m4v",
                                    size: {
                                        width: "100%",
                                        height: "360px",
                                        cssClass: "jp-video-360p"
                                    }
                                });
                            });
                            //]]>
                            //jQuery("#jplayer_inspector").jPlayerInspector({ jPlayer: jQuery("#player_video_") });
                        </script>
                    </figure>
                    <?php } break;

                case 'url': {
                        ?>
                    <figure class="featured-post-figure quotation" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
                        <hgroup>
                            <a href="<?php echo esc_url(get_post_meta($post->ID, 'serpentsoft_url_destination', true)); ?>"
                               title="<?php echo esc_attr(get_post_meta($post->ID, 'serpentsoft_url_text', true)); ?>" target="_blank">
                                <h3><?php echo get_post_meta($post->ID, 'serpentsoft_url_text', true); ?></h3>
                            </a>
                        </hgroup>

                        <figcaption itemprop="description"><?php echo get_post_meta($post->ID, 'serpentsoft_post_banner_caption', true); ?></figcaption>
                    </figure>
                    <?php } break;

                case 'none': { ?>

                <?php } break;

            default: { ?>
                    <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">

                    <?php $img_post = serpentsoft_post_featured_image('post', $post->ID, array('itemprop' => 'contentURL'));
                    if ($img_post != '') {
                        $xpath = new DOMXPath(@DOMDocument::loadHTML($img_post));
                        $src = $xpath->evaluate("string(//img/@src)");
                    } ?>
                        <figcaption itemprop="description">
                    <?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?>
                        </figcaption>
                    </figure>
                <?php } break; 
            }

    // Old Posts
    else: ?>
        <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">

        <?php $img_post = serpentsoft_post_featured_image('post', $post->ID, array('itemprop' => 'contentURL'));

        if ($img_post != '') {
            $xpath = new DOMXPath(@DOMDocument::loadHTML($img_post));
            $src = $xpath->evaluate("string(//img/@src)");
        } ?>

            <figcaption itemprop="description">
        <?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?>
            </figcaption>
        </figure>

    <?php endif;
} ?>