Exemple #1
0
function axiom_sc_zoom($atts, $content = null)
{
    if (axiom_sc_in_shortcode_blogger()) {
        return '';
    }
    extract(axiom_sc_html_decode(shortcode_atts(array("effect" => "zoom", "src" => "", "url" => "", "over" => "", "align" => "", "bg_image" => "", "bg_top" => '', "bg_bottom" => '', "bg_left" => '', "bg_right" => '', "id" => "", "class" => "", "animation" => "", "css" => "", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts)));
    axiom_enqueue_script('axiom-elevate-zoom-script', axiom_get_file_url('js/jquery.elevateZoom-3.0.4.js'), array(), null, true);
    $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);
    $width = axiom_prepare_css_value($width);
    $height = axiom_prepare_css_value($height);
    if (empty($id)) {
        $id = 'sc_zoom_' . str_replace('.', '', mt_rand());
    }
    $src = $src != '' ? $src : $url;
    if ($src > 0) {
        $attach = wp_get_attachment_image_src($src, 'full');
        if (isset($attach[0]) && $attach[0] != '') {
            $src = $attach[0];
        }
    }
    if ($over > 0) {
        $attach = wp_get_attachment_image_src($over, 'full');
        if (isset($attach[0]) && $attach[0] != '') {
            $over = $attach[0];
        }
    }
    if ($effect == 'lens' && ((int) $width > 0 && axiom_substr($width, -2, 2) == 'px') || (int) $height > 0 && axiom_substr($height, -2, 2) == 'px') {
        if ($src) {
            $src = axiom_get_resized_image_url($src, (int) $width > 0 && axiom_substr($width, -2, 2) == 'px' ? (int) $width : null, (int) $height > 0 && axiom_substr($height, -2, 2) == 'px' ? (int) $height : null);
        }
        if ($over) {
            $over = axiom_get_resized_image_url($over, (int) $width > 0 && axiom_substr($width, -2, 2) == 'px' ? (int) $width : null, (int) $height > 0 && axiom_substr($height, -2, 2) == 'px' ? (int) $height : null);
        }
    }
    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;
    }
    $output = empty($src) ? '' : (!empty($bg_image) ? '<div class="sc_zoom_wrap' . (!empty($class) ? ' ' . esc_attr($class) : '') . ($align && $align != 'none' ? ' align' . esc_attr($align) : '') . '"' . (!axiom_sc_param_is_off($animation) ? ' data-animation="' . esc_attr(axiom_sc_get_animation_classes($animation)) . '"' : '') . ($css_bg != '' ? ' style="' . esc_attr($css_bg) . '"' : '') . '>' : '') . '<div' . ($id ? ' id="' . esc_attr($id) . '"' : '') . ' class="sc_zoom' . (empty($bg_image) && !empty($class) ? ' ' . esc_attr($class) : '') . (empty($bg_image) && $align && $align != 'none' ? ' align' . esc_attr($align) : '') . '"' . (empty($bg_image) && !axiom_sc_param_is_off($animation) ? ' data-animation="' . esc_attr(axiom_sc_get_animation_classes($animation)) . '"' : '') . ($css != '' ? ' style="' . esc_attr($css) . '"' : '') . '>' . '<img src="' . esc_url($src) . '"' . ($css_dim != '' ? ' style="' . esc_attr($css_dim) . '"' : '') . ' data-zoom-image="' . esc_url($over) . '" alt="" />' . '</div>' . (!empty($bg_image) ? '</div>' : '');
    return apply_filters('axiom_shortcode_output', $output, 'trx_zoom', $atts, $content);
}
Exemple #2
0
 function axiom_get_css_paddings_from_values($padding_top = '', $padding_right = '', $padding_bottom = '', $padding_left = '')
 {
     if (!is_array($padding_top)) {
         $padding_top = compact('padding_top', 'padding_right', 'padding_bottom', 'padding_left');
     }
     $output = '';
     foreach ($padding_top as $k => $v) {
         if ($v == '') {
             continue;
         }
         $imp = axiom_substr($v, 0, 1);
         if ($imp == '!') {
             $v = axiom_substr($v, 1);
         }
         $output .= str_replace('_', '-', $k) . ':' . trim(axiom_prepare_css_value($v)) . ($imp == '!' ? ' !important' : '') . ';';
     }
     return $output;
 }