<?php
foreach ($videoArry as $photo) {



    $url = $photo['var_youtubeurl'];

    $urls = parse_url($url);

//Expect the URL to be http://youtu.be/abcd, where abcd is the video ID
    if ($urls['host'] == 'youtu.be') :

        $imgPath = ltrim($urls['path'], '/');

//Expect the URL to be http://www.youtube.com/embed/abcd
    elseif (strpos($urls['path'], 'embed') == 1) :

        $imgPath = end(explode('/', $urls['path']));

//Expect the URL to be abcd only
    elseif (strpos($url, '/') === false):

        $imgPath = $url;

//Expect the URL to be http://www.youtube.com/watch?v=abcd
    else :

        parse_str($urls['query']);

        $imgPath = $v;

    endif;
$thumb1 = "http://img.youtube.com/vi/$imgPath/0.jpg";
//echo $imgPath;exit;
//    $photo_thumb = $photo['var_image'];
//    $thumb = "../upimages/videogallery/images/" . $photo_thumb;
//    if (file_exists($thumb)) {
//        $thumbphoto = SITE_PATH . "upimages/videogallery/images/" . $photo_thumb;
//    } else {
//        $thumbphoto = 'images/admin-image.jpg';
//    }
    $selected = ($photo['var_primary'] == 'Y') ? 'photo-default-icon active' : 'photo-default-icon';
    $display = ($photo['chr_publish'] == 'Y') ? 'publish-icon active' : 'publish-icon';
    $display_title = ($photo['chr_publish'] == 'Y') ? 'Publish' : 'Unpublish';
    $shareimg = "1-push.png";
    ?>
    <!-- Photo Gallery Start -->
    <li data-itemid="<?php echo $photo['int_displayorder']; ?>" id="<?= $photo['int_glcode'] ?>">
        <div class="photo-wrapper">        
            <div class="photo-wrapper-img" > 
                <table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="270" height="161" align="center" valign="middle" id="drg-img-div">
                            <img src="<?= $thumb1 ?>" alt="photos" id="drg-img" style="cursor: pointer;"  />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="photo-caption">
                <textarea name="varphotocaption" cols="" rows="" id="varphotocaption_<?= $photo['int_glcode'] ?>" ><?php echo $photo['var_title']; ?></textarea>
            </div>
            <div class="photo-icons">

                <a href="javascript:void(0);" onclick="deletealbumphoto('<?= $photo['int_glcode'] ?>')" class="delete-icon" title="Delete Video"></a>
                <a href="javascript:void(0);" onclick="savealbumcaption('<?= $photo['int_glcode'] ?>')" class="save-icon" title="Save Caption"></a>
                <a href="javascript:void(0);" onclick="setpublish_unpublish('<?= $photo['int_glcode'] ?>','<?= $photo['chr_publish'] ?>');" class="<?= $display ?>" title="<?= $display_title ?>"></a>
                <a href="javascript:void(0);" onclick="return openLinksModel(<?php echo $photo['int_glcode']; ?>);" ><img width="45" height="30" src="<?php echo $thumb1 ?>" /></a>
                &nbsp;
                <!--<img id="shar-<?= $photo['int_glcode'] ?>" height="25" width="77" alt="<?= $photo['var_title'] . "share" ?>" title="<?= $photo['var_title'] . " is share." ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $shareimg ?>" class="publish-icon" style="width:77px !important;height: 25px !important; margin-top: 5px;cursor:pointer;<?= $display ?>" onclick="share(<?= $photo['int_glcode'] ?>);">-->
            </div>
        </div>       
    </li>
    <?php
}
?>