Example #1
0
function yit_detect_span_catalog_image()
{
    global $woocommerce_loop, $yit_is_feature_tab, $post;
    $sidebar = yit_get_sidebar_layout() == 'sidebar-no' ? 'no' : 'yes';
    $content_width = $sidebar == 'no' ? 1170 : 870;
    if (isset($yit_is_feature_tab) && $yit_is_feature_tab) {
        $content_width -= 300;
    }
    $product_width = yit_shop_catalog_w() + ($woocommerce_loop['layout'] == 'classic' ? 6 : 10) + 2;
    // 10 = padding & 2 = border
    $is_span = false;
    if (get_option('woocommerce_responsive_images') == 'yes') {
        $is_span = true;
        if ($sidebar == 'no') {
            if ($product_width >= 0 && $product_width < 120) {
                $woocommerce_loop['li_class'][] = 'span1';
                $woocommerce_loop['columns'] = 12;
            } elseif ($product_width >= 120 && $product_width < 220) {
                $woocommerce_loop['li_class'][] = 'span2';
                $woocommerce_loop['columns'] = 6;
            } elseif ($product_width >= 220 && $product_width < 320) {
                $woocommerce_loop['li_class'][] = 'span3';
                $woocommerce_loop['columns'] = 4;
            } elseif ($product_width >= 320 && $product_width < 470) {
                $woocommerce_loop['li_class'][] = 'span4';
                $woocommerce_loop['columns'] = 3;
            } elseif ($product_width >= 470 && $product_width < 620) {
                $woocommerce_loop['li_class'][] = 'span6';
                $woocommerce_loop['columns'] = 2;
            } else {
                $is_span = false;
            }
        } else {
            if ($product_width >= 0 && $product_width < 150) {
                $woocommerce_loop['li_class'][] = 'span1';
                $woocommerce_loop['columns'] = 12;
            } elseif ($product_width >= 150 && $product_width < 620) {
                $woocommerce_loop['li_class'][] = 'span3';
                $woocommerce_loop['columns'] = 3;
            } else {
                $is_span = false;
            }
        }
    } else {
        $grid = yit_get_span_from_width($product_width);
        $woocommerce_loop['li_class'][] = 'span' . $grid;
        $product_width = yit_width_of_span($grid);
    }
    if ($yit_is_feature_tab || !$is_span) {
        $woocommerce_loop['columns'] = floor(($content_width + 30) / ($product_width + 30));
    }
}
Example #2
0
        if ( $product_width >= 0   && $product_width < 120 ) { $woocommerce_loop['li_class'][] = 'span1'; $woocommerce_loop['columns'] = 12; }
        elseif ( $product_width >= 120 && $product_width < 220 ) { $woocommerce_loop['li_class'][] = 'span2'; $woocommerce_loop['columns'] = 6;  }
        elseif ( $product_width >= 220 && $product_width < 320 ) { $woocommerce_loop['li_class'][] = 'span3'; $woocommerce_loop['columns'] = 4;  }
        elseif ( $product_width >= 320 && $product_width < 470 ) { $woocommerce_loop['li_class'][] = 'span4'; $woocommerce_loop['columns'] = 3;  }
        elseif ( $product_width >= 470 && $product_width < 620 ) { $woocommerce_loop['li_class'][] = 'span6'; $woocommerce_loop['columns'] = 2;  }
        else $is_span = false;

    } else {
        if ( $product_width >= 0   && $product_width < 150 ) { $woocommerce_loop['li_class'][] = 'span1'; $woocommerce_loop['columns'] = 9; }
        elseif ( $product_width >= 150 && $product_width < 620 ) { $woocommerce_loop['li_class'][] = 'span3'; $woocommerce_loop['columns'] = 3;  }
        else $is_span = false;

    }

} else {
    $grid = yit_get_span_from_width( $product_width );
    $woocommerce_loop['li_class'][] = 'span' . $grid;
    $product_width = yit_width_of_span( $grid );
}
if ( $yit_is_feature_tab || ! $is_span ) $woocommerce_loop['columns'] = floor( ( $content_width + 30 ) / ( $product_width + 30 ) );

// put the percentual width
// if ( ! $is_span ) {
//     $woocommerce_loop['li_class'][] = 'no-span';
//     $perc = ( 100 - $woocommerce_loop['columns'] * 3 ) / $woocommerce_loop['columns'];
//     $style_attr = " style='width:$perc%;'";
// }

$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', $woocommerce_loop['columns'] );

// first and last
Example #3
0
function yit_print_image_responsive_enabled_variables() {
    global $woocommerce_loop, $yit_is_feature_tab;

    $content_width = yit_get_sidebar_layout() == 'sidebar-no' ? 1170 : 870;
    if ( isset( $yit_is_feature_tab ) && $yit_is_feature_tab ) {
        $content_width -= 300;
    }
    $product_width = yit_shop_small_w() + 10 + 2; // 10 = padding & 2 = border
    $is_span       = false;
    if ( get_option( 'woocommerce_responsive_images' ) == 'yes' ) {
        $is_span = true;
        if ( yit_get_sidebar_layout() == 'sidebar-no' ) {
            if ( $product_width >= 0 && $product_width < 120 ) {
                $woocommerce_loop['li_class'][] = 'span1';
                $woocommerce_loop['columns']    = 12;
            }
            elseif ( $product_width >= 120 && $product_width < 220 ) {
                $woocommerce_loop['li_class'][] = 'span2';
                $woocommerce_loop['columns']    = 6;
            }
            elseif ( $product_width >= 220 && $product_width < 320 ) {
                $woocommerce_loop['li_class'][] = 'span3';
                $woocommerce_loop['columns']    = 4;
            }
            elseif ( $product_width >= 320 && $product_width < 470 ) {
                $woocommerce_loop['li_class'][] = 'span4';
                $woocommerce_loop['columns']    = 3;
            }
            elseif ( $product_width >= 470 && $product_width < 620 ) {
                $woocommerce_loop['li_class'][] = 'span6';
                $woocommerce_loop['columns']    = 2;
            }
            else {
                $is_span = false;
            }

        }
        else {
            if ( $product_width >= 0 && $product_width < 150 ) {
                $woocommerce_loop['li_class'][] = 'span1';
                $woocommerce_loop['columns']    = 12;
            }
            elseif ( $product_width >= 150 && $product_width < 620 ) {
                $woocommerce_loop['li_class'][] = 'span3';
                $woocommerce_loop['columns']    = 3;
            }
            else {
                $is_span = false;
            }

        }

    }
    else {
        $grid                           = yit_get_span_from_width( $product_width );
        $woocommerce_loop['li_class'][] = 'span' . $grid;
        $product_width                  = yit_width_of_span( $grid );
    }
    if ( $yit_is_feature_tab || ! $is_span ) {
        $woocommerce_loop['columns'] = floor( ( $content_width + 30 ) / ( $product_width + 30 ) );
    }
    ?>
    <script type="text/javascript">
        var elastislide_defaults = {
            imageW              : <?php echo get_option('woocommerce_responsive_images') == 'no' || ! get_option('woocommerce_responsive_images') ? yit_shop_small_w() + 10 + 2 : '"100%"'; ?>,
            border              : 0,
            margin              : 0,
            preventDefaultEvents: false,
            infinite            : true,
            slideshowSpeed      : 3500
        };

        var carouFredSelOptions_defaults = {
            responsive: false,
            auto      : true,
            items     : <?php echo empty( $woocommerce_loop['columns'] ) ? 0 : $woocommerce_loop['columns'] ?>,
            circular  : true,
            infinite  : true,
            debug     : false,
            prev      : '.es-nav .es-nav-prev',
            next      : '.es-nav .es-nav-next',
            swipe     : {
                onTouch: false
            },
            scroll    : {
                items       : 1,
                pauseOnHover: true
            }
        };


    </script>
<?php
}