コード例 #1
0
 $video_file = $gallery_item['video_file'];
 $video_resolution = $gallery_item['video_resolution'];
 $player_options = $gallery_item['player_options'];
 $video_poster = $gallery_item['video_poster'];
 $video_file_pathinfo = pathinfo($video_file['url']);
 # Check Type
 if (!isset($video_file_pathinfo['extension']) || !in_array(strtolower($video_file_pathinfo['extension']), array('mp4', 'webm', 'ogv'))) {
     continue;
 }
 # Video Resolution
 if (!preg_match("/^[0-9]+:[0-9]+\$/", $video_resolution)) {
     $video_resolution = "16:9";
 }
 $video_resolution = explode(":", $video_resolution);
 # Generate Video Height
 $video_el_id = laborator_generate_as_element(array($video_resolution[0], $video_resolution[1]));
 # Player Skin
 $player_skin = 'vjs-default-skin';
 if ($player_options == 'minimal') {
     $player_skin = 'vjs-sublime-skin';
 }
 # Prepare Video
 $videojs_atts = "data-setup=\"{}\" preload=\"auto\"";
 if ($video_poster && $video_poster['url']) {
     $videojs_atts .= ' poster="' . $video_poster['url'] . '"';
 }
 $video_shortcode = do_shortcode("[video src=\"{$video_file['url']}\"]");
 $video_shortcode = preg_replace(array('/<div.*?>.*?(<video.*?<\\/video>).*?<\\/div.*?>/s', '/(width|height)=".*?"\\s?/'), array('\\1', ''), $video_shortcode);
 $video_shortcode = str_replace(array('wp-video-shortcode', '<video'), array('video-js ' . $player_skin . ' auto-width', '<video ' . $videojs_atts), $video_shortcode);
 # Enqueue Scripts
 wp_enqueue_script(array('video-js'));
コード例 #2
0
# End of: Post Format - Video
?>

<?php 
# Post Format - Audio
if ($post_format == 'audio' && $post_audio['content']) {
    ?>

	<?php 
    $blog_post_format_parsed = true;
    wp_enqueue_script('video-js');
    wp_enqueue_style('video-js');
    if ($post_thumbnail_id) {
        $img_attachment = wp_get_attachment_image_src($post_thumbnail_id, $thumb_size);
        if ($img_attachment) {
            $audio_element_aspect_ratio = laborator_generate_as_element(array($img_attachment[1], $img_attachment[2]));
        }
    }
    ?>
	<div class="music-video-holder video-type-audio <?php 
    echo isset($audio_element_aspect_ratio) ? $audio_element_aspect_ratio : '';
    ?>
">
		<?php 
    echo $post_audio['content'];
    # generated by [audio] shortcode
    ?>
	</div>

<?php 
}
コード例 #3
0
 *	Kalium WordPress Theme
 *	
 *	Laborator.co
 *	www.laborator.co 
 */
// When There is no post thumbnail
if (is_single() && !$post_thumbnail_id) {
    return;
}
$post_image = wp_get_attachment_image_src($post_thumbnail_id, $thumb_size);
?>
<a href="<?php 
echo is_single() && is_array($post_image) ? $post_image[0] : $permalink;
?>
">
<?php 
if ($post_thumbnail_id) {
    laborator_show_image_placeholder($post_thumbnail_id, $thumb_size, '', $blog_post_list_lazy_load);
} else {
    $element_id = laborator_generate_as_element($default_image_size);
    ?>
	<span class="default-thumbnail-placeholder <?php 
    echo esc_attr($element_id);
    ?>
"></span>
	<?php 
}
// Hover State
include locate_template('tpls/post-hover.php');
?>
</a>
コード例 #4
0
function laborator_show_image_placeholder($attachment_id, $size = 'original', $class = '', $lazy_load = true, $img_class = 'visibility-hidden')
{
    if (is_string($size) && preg_match('/^[0-9]+(x[0-9]+)?$/', $size)) {
        $size = explode('x', $size);
    }
    if (is_array($size)) {
        if (count($size) == 2) {
            $size['bfi_thumb'] = true;
            $size['crop'] = true;
            $size['quality'] = 90;
        }
    }
    if (is_numeric($attachment_id)) {
        $image = wp_get_attachment_image_src($attachment_id, $size);
        $alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
        $extension = pathinfo($image[0], PATHINFO_EXTENSION);
        // SVG
        $pathinfo_image = pathinfo($image[0]);
        if ($extension == 'svg' && function_exists('simplexml_load_file')) {
            $svgfile = simplexml_load_file($image[0]);
            if (isset($svgfile->rect)) {
                $width = reset($svgfile->rect['width']);
                $height = reset($svgfile->rect['height']);
                $image = array($image[0], $width, $height);
            }
        }
        // Show gifs in original size
        if ($extension == 'gif') {
            $image = wp_get_attachment_image_src($attachment_id, 'full');
        }
    } else {
        $image = array($attachment_id, $size[0], $size[1]);
    }
    $thumb_size = array($image[1], $image[2]);
    $element_id = laborator_generate_as_element($thumb_size);
    $placeholder_class = array();
    $placeholder_class[] = 'image-placeholder';
    $placeholder_class[] = $element_id;
    if ($class) {
        $placeholder_class[] = trim($class);
    }
    if (!$lazy_load) {
        $img_class = str_replace('visibility-hidden', '', $img_class);
    }
    ?>
	<span class="<?php 
    echo implode(' ', apply_filters('lab_image_placeholder_class', $placeholder_class));
    ?>
">
		<img <?php 
    echo apply_filters('lab_image_placeholder_lazyload', $lazy_load) ? 'data-' : '';
    ?>
src="<?php 
    echo esc_url($image[0]);
    ?>
" width="<?php 
    echo esc_attr($thumb_size[0]);
    ?>
" height="<?php 
    echo esc_attr($thumb_size[1]);
    ?>
" class="<?php 
    echo esc_attr($img_class);
    ?>
" alt="<?php 
    echo esc_attr(!empty($alt) ? $alt : "img-{$attachment_id}");
    ?>
" />
	</span>
	<?php 
}