Ejemplo n.º 1
0
<?php

if ($post_data['post_video']) {
    echo trim(axiom_get_video_frame($post_data['post_video'], $post_data['post_video_image'] ? $post_data['post_video_image'] : $post_data['post_thumb']));
} else {
    if ($post_data['post_audio']) {
        echo trim(axiom_get_audio_frame($post_data['post_audio'], $post_data['post_audio_image'] ? $post_data['post_audio_image'] : $post_data['post_thumb_url']));
    } else {
        if ($post_data['post_thumb'] && ($post_data['post_format'] != 'gallery' || !$post_data['post_gallery'] || axiom_get_custom_option('gallery_instead_image') == 'no')) {
            ?>
						<div class="post_thumb" data-image="<?php 
            echo esc_url($post_data['post_attachment']);
            ?>
" data-title="<?php 
            echo esc_attr($post_data['post_title']);
            ?>
">
						<?php 
            if ($post_data['post_format'] == 'link' && $post_data['post_url'] != '') {
                echo '<a class="hover_icon hover_icon_link" href="' . esc_url($post_data['post_url']) . '"' . ($post_data['post_url_target'] ? ' target="' . esc_attr($post_data['post_url_target']) . '"' : '') . '>' . $post_data['post_thumb'] . '</a>';
            } else {
                if ($post_data['post_link'] != '') {
                    echo '<a class="hover_icon hover_icon_link" href="' . esc_url($post_data['post_link']) . '">' . $post_data['post_thumb'] . '</a>';
                } else {
                    echo trim($post_data['post_thumb']);
                }
            }
            ?>
						</div>
						<?php 
        } else {
Ejemplo n.º 2
0
function axiom_sc_video($atts, $content = null)
{
    if (axiom_sc_in_shortcode_blogger()) {
        return '';
    }
    extract(axiom_sc_html_decode(shortcode_atts(array("url" => '', "src" => '', "image" => '', "ratio" => '16:9', "autoplay" => 'off', "align" => '', "bg_image" => '', "bg_top" => '', "bg_bottom" => '', "bg_left" => '', "bg_right" => '', "frame" => "on", "id" => "", "class" => "", "animation" => "", "css" => "", "width" => '', "height" => '', "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts)));
    $ratio = empty($ratio) ? "16:9" : str_replace(array('/', '\\', '-'), ':', $ratio);
    $ratio_parts = explode(':', $ratio);
    if (empty($height) && empty($width)) {
        $width = '100%';
    }
    $ed = axiom_substr($width, -1);
    if (empty($height) && !empty($width) && $ed != '%') {
        $height = round($width / $ratio_parts[0] * $ratio_parts[1]);
    }
    if (!empty($height) && empty($width)) {
        $width = round($height * $ratio_parts[0] / $ratio_parts[1]);
    }
    $css .= axiom_get_css_position_from_values($top, $right, $bottom, $left);
    $css_dim = axiom_get_css_position_from_values('', '', '', '', $width, $height);
    $css_bg = axiom_get_css_paddings_from_values($bg_top, $bg_right, $bg_bottom, $bg_left);
    if ($src == '' && $url == '' && isset($atts[0])) {
        $src = $atts[0];
    }
    $url = $src != '' ? $src : $url;
    if ($image != '' && axiom_sc_param_is_off($image)) {
        $image = '';
    } else {
        if (axiom_sc_param_is_on($autoplay) && is_single()) {
            $image = '';
        } else {
            if ($image > 0) {
                $attach = wp_get_attachment_image_src($image, 'full');
                if (isset($attach[0]) && $attach[0] != '') {
                    $image = $attach[0];
                }
            }
            if ($bg_image) {
                $thumb_sizes = axiom_get_thumb_sizes(array('layout' => 'grid_3'));
                $image = axiom_get_resized_image_url(empty($image) ? get_the_ID() : $image, $thumb_sizes['w'], $thumb_sizes['h'], null, false, false, false);
            } else {
                $image = axiom_get_resized_image_url(empty($image) ? get_the_ID() : $image, $ed != '%' ? $width : null, $height);
            }
            if (empty($image)) {
                $image = axiom_get_video_cover_image($url);
            }
        }
    }
    if ($bg_image > 0) {
        $attach = wp_get_attachment_image_src($bg_image, 'full');
        if (isset($attach[0]) && $attach[0] != '') {
            $bg_image = $attach[0];
        }
    }
    if ($bg_image) {
        $css_bg .= $css . 'background-image: url(' . esc_url($bg_image) . ');';
        $css = $css_dim;
    } else {
        $css .= $css_dim;
    }
    $url = axiom_get_video_player_url($src != '' ? $src : $url);
    $video = '<video' . ($id ? ' id="' . esc_attr($id) . '"' : '') . ' class="sc_video' . (!empty($class) ? ' ' . esc_attr($class) : '') . '"' . ' src="' . esc_url($url) . '"' . ' width="' . esc_attr($width) . '" height="' . esc_attr($height) . '"' . ' data-width="' . esc_attr($width) . '" data-height="' . esc_attr($height) . '"' . ' data-ratio="' . esc_attr($ratio) . '"' . ($image ? ' poster="' . esc_attr($image) . '" data-image="' . esc_attr($image) . '"' : '') . (!axiom_sc_param_is_off($animation) ? ' data-animation="' . esc_attr(axiom_sc_get_animation_classes($animation)) . '"' : '') . ($align && $align != 'none' ? ' data-align="' . esc_attr($align) . '"' : '') . ($bg_image ? ' data-bg-image="' . esc_attr($bg_image) . '"' : '') . ($css_bg != '' ? ' data-style="' . esc_attr($css_bg) . '"' : '') . ($css != '' ? ' style="' . esc_attr($css) . '"' : '') . ($image && axiom_get_theme_option('substitute_video') == 'yes' || axiom_sc_param_is_on($autoplay) && is_single() ? ' autoplay="autoplay"' : '') . ' controls="controls" loop="loop"' . '>' . '</video>';
    if (axiom_get_custom_option('substitute_video') == 'no') {
        if (axiom_sc_param_is_on($frame)) {
            $video = axiom_get_video_frame($video, $image, $css, $css_bg);
        }
    } else {
        if (isset($_GET['vc_editable']) && $_GET['vc_editable'] == 'true' && (isset($_POST['action']) && $_POST['action'] == 'vc_load_shortcode')) {
            $video = axiom_substitute_video($video, $width, $height, false);
        }
    }
    if (axiom_get_theme_option('use_mediaelement') == 'yes') {
        axiom_enqueue_script('wp-mediaelement');
    }
    return apply_filters('axiom_shortcode_output', $video, 'trx_video', $atts, $content);
}
Ejemplo n.º 3
0
 function axiom_substitute_video($post_text, $w, $h, $in_frame = true)
 {
     $tag = '<video>';
     $tag_end = '</video>';
     $pos_start = -1;
     while (($pos_start = axiom_strpos($post_text, axiom_substr($tag, 0, -1) . ' ', $pos_start + 1)) !== false) {
         $pos_end = axiom_strpos($post_text, axiom_substr($tag, -1), $pos_start);
         $pos_end2 = axiom_strpos($post_text, $tag_end, $pos_end);
         $tag_text = axiom_substr($post_text, $pos_start, ($pos_end2 !== false ? $pos_end2 + axiom_strlen($tag_end) - 1 : $pos_end) - $pos_start + 1);
         if (axiom_get_tag_attrib($tag_text, $tag, 'data-frame') == 'no') {
             continue;
         }
         if (($src = axiom_get_tag_attrib($tag_text, $tag, 'src')) == '') {
             $src = axiom_get_tag_attrib($tag_text, $tag, 'url');
         }
         if ($src != '') {
             $auto = axiom_get_tag_attrib($tag_text, $tag, 'autoplay');
             $src = axiom_get_video_player_url($src, $auto != '');
             // && is_single());
             $id = axiom_get_tag_attrib($tag_text, $tag, 'id');
             $tag_w = axiom_get_tag_attrib($tag_text, $tag, 'width');
             $tag_h = axiom_get_tag_attrib($tag_text, $tag, 'height');
             $tag_a = axiom_get_tag_attrib($tag_text, $tag, 'align');
             if (!$tag_a) {
                 $tag_a = axiom_get_tag_attrib($tag_text, $tag, 'data-align');
             }
             $tag_s = axiom_get_tag_attrib($tag_text, $tag, 'style');
             $tag_s2 = axiom_get_tag_attrib($tag_text, $tag, 'data-style');
             $tag_c = axiom_get_tag_attrib($tag_text, $tag, 'controls');
             $tag_l = axiom_get_tag_attrib($tag_text, $tag, 'loop');
             $video = '<iframe' . ($id ? ' id="' . esc_attr($id) . '"' : '') . ' class="video_frame' . (!$in_frame && $tag_a ? ' align' . esc_attr($tag_a) : '') . '"' . ' src="' . esc_url($src) . '"' . ' width="' . esc_attr($tag_w ? $tag_w : $w) . '"' . ' height="' . esc_attr($tag_h ? $tag_h : $h) . '"' . ($tag_a ? ' data-align="' . esc_attr($tag_a) . '"' : '') . ' frameborder="0" webkitAllowFullScreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowFullScreen="allowFullScreen"></iframe>';
             if ($in_frame) {
                 $tag_image = axiom_get_tag_attrib($tag_text, $tag, 'data-image');
                 $video = axiom_get_video_frame($video, $tag_image, $tag_s, $tag_s2);
             }
             $pos_end = $pos_end2 !== false ? $pos_end2 + 8 : $pos_end + 1;
             $post_text = axiom_substr($post_text, 0, axiom_substr($post_text, $pos_start - 3, 3) == '<p>' ? $pos_start - 3 : $pos_start) . $video . axiom_substr($post_text, axiom_substr($post_text, $pos_end, 4) == '</p>' ? $pos_end + 4 : $pos_end);
         }
     }
     return $post_text;
 }