public static function change_image_in_cart_page($product_image, $values, $cart_item_key)
 {
     if (is_array($values) && isset($values['variation_id']) && $values['variation_id'] > 0) {
         return $product_image;
     } elseif (isset($values['product_id']) && $values['product_id'] > 0) {
         $product_id = $values['product_id'];
         // Don't change the image if product has featured image
         if (has_post_thumbnail($product_id)) {
             return $product_image;
         }
         $dgallery_ids = WC_Dynamic_Gallery_Functions::get_gallery_ids($product_id);
         if (is_array($dgallery_ids) && count($dgallery_ids) > 0) {
             // Use first image from variation gallery
             $img_id = (int) array_shift($dgallery_ids);
             $product_image = wp_get_attachment_image($img_id, 'shop_thumbnail');
         }
     }
     return $product_image;
 }
Esempio n. 2
0
$g_height = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_height');
$g_thumb_width = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_width');
if ($g_thumb_width <= 0) {
    $g_thumb_width = 105;
}
$g_thumb_height = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_height');
if ($g_thumb_height <= 0) {
    $g_thumb_height = 75;
}
$g_thumb_spacing = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_spacing');
$bg_nav_color = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'bg_nav_color');
$bg_image_wrapper = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'bg_image_wrapper');
$border_image_wrapper_color = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'border_image_wrapper_color');
$product_gallery_bg_des = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_bg_des');
$des_background = str_replace('#', '', $product_gallery_bg_des);
$bg_des = WC_Dynamic_Gallery_Functions::html2rgb($product_gallery_bg_des, true);
$enable_gallery_thumb = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'enable_gallery_thumb');
$product_gallery_nav = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_nav');
$lazy_load_scroll = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'lazy_load_scroll');
$transition_scroll_bar = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'transition_scroll_bar');
$caption_font = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'caption_font');
$navbar_font = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'navbar_font');
$navbar_height = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'navbar_height');
if ('yes' == $product_gallery_nav) {
    $display_ctrl = 'display:block !important;';
    $mg = $navbar_height;
    $ldm = $navbar_height;
} else {
    $display_ctrl = 'display:none !important;';
    $mg = '0';
    $ldm = '0';
    public function woocommerce_product_image_box()
    {
        global $post;
        $wc_dgallery_hide_woo_gallery = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'hide_woo_gallery', 'no');
        $global_wc_dgallery_activate = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'activate');
        $actived_d_gallery = get_post_meta($post->ID, '_actived_d_gallery', true);
        if ($actived_d_gallery == '' && $global_wc_dgallery_activate != 'no') {
            $actived_d_gallery = 1;
        }
        wp_enqueue_style('a3-dynamic-metabox-admin-style');
        if (is_rtl()) {
            wp_enqueue_style('a3-dynamic-metabox-admin-style-rtl');
        }
        wp_enqueue_script('a3-dynamic-metabox-admin-script');
        wp_localize_script('a3-dynamic-metabox-admin-script', 'a3_dgallery_metabox', array('ajax_url' => admin_url('admin-ajax.php', 'relative')));
        wp_enqueue_media();
        ob_start();
        ?>
		<style>
		#woocommerce-product-images {
		<?php 
        if ($actived_d_gallery == 1 && $wc_dgallery_hide_woo_gallery == 'yes') {
            ?>
			display: none;
		<?php 
        } else {
            ?>
			display: block;
		<?php 
        }
        ?>
		}
        </style>
        <div class="a3rev_panel_container a3-metabox-panel-wrap a3-dynamic-metabox-panel-wrap" style="padding-left: 0px;">

			<div style="margin-bottom:10px;">
        		<label class="a3_actived_d_gallery" style="margin-right: 50px;">
        			<input type="checkbox" <?php 
        checked(1, $actived_d_gallery, true);
        ?>
 value="1" name="actived_d_gallery" class="actived_d_gallery" /> 
        			<?php 
        echo __('A3 Dynamic Image Gallery activated', 'woo_dgallery');
        ?>
        		</label>
        	</div>

			<div id="main_dgallery_panel" class="dgallery_images_container a3-metabox-panel a3-metabox-options-panel" style="<?php 
        if (1 != $actived_d_gallery) {
            echo 'display: none;';
        }
        ?>
">

				<ul class="dgallery_images">
					<?php 
        $dgallery_ids = WC_Dynamic_Gallery_Functions::get_gallery_ids($post->ID);
        if (is_array($dgallery_ids) && count($dgallery_ids) > 0) {
            foreach ($dgallery_ids as $img_id) {
                $img_data = wp_get_attachment_image_src($img_id, 'thumbnail');
                ?>
					<li class="image" data-attachment_id="<?php 
                echo $img_id;
                ?>
">
						<img class="image_item" src="<?php 
                echo $img_data['0'];
                ?>
" />
						<ul class="actions">
							<li><a href="#" class="delete dg_tips" data-tip="<?php 
                echo __('Delete image', 'woo_dgallery');
                ?>
"><?php 
                echo __('Delete image', 'woo_dgallery');
                ?>
</a></li>
						</ul>
					</li>
					<?php 
            }
        }
        ?>
				</ul>

				<input type="hidden" class="dgallery_ids" name="dgallery_ids" value="<?php 
        if ($dgallery_ids) {
            echo esc_attr(implode(',', $dgallery_ids));
        }
        ?>
" />

				<p class="add_dgallery_images hide-if-no-js">
					<a href="#" data-choose="<?php 
        _e('Add Images to Dynamic Gallery', 'woo_dgallery');
        ?>
" data-update="<?php 
        _e('Add to gallery', 'woo_dgallery');
        ?>
" data-delete="<?php 
        _e('Delete image', 'woo_dgallery');
        ?>
" data-text="<?php 
        _e('Delete', 'woo_dgallery');
        ?>
"><?php 
        _e('Add dynamic gallery images', 'woo_dgallery');
        ?>
</a>
				</p>

			</div>

			<?php 
        // Add an nonce field so we can check for it later.
        wp_nonce_field('a3_dynamic_metabox_action', 'a3_dynamic_metabox_nonce_field');
        ?>
			<div style="clear: both;"></div>

		</div>
		<div style="clear: both;"></div>

        <script type="text/javascript">
		jQuery(document).ready(function() {
			jQuery('input.actived_d_gallery').change(function() {
				if( jQuery(this).is(":checked") ) {
					<?php 
        if ($wc_dgallery_hide_woo_gallery == 'yes') {
            ?>
					jQuery('#woocommerce-product-images').slideUp();
					<?php 
        }
        ?>
				} else {
					jQuery('#woocommerce-product-images').slideDown();
				}
			});
		});
		</script>
        <?php 
        $output = ob_get_clean();
        echo $output;
    }
Esempio n. 4
0
 public function after_save_settings()
 {
     if (isset($_POST['bt_save_settings']) && isset($_POST[WOO_DYNAMIC_GALLERY_PREFIX . 'reset_galleries_activate'])) {
         delete_option(WOO_DYNAMIC_GALLERY_PREFIX . 'reset_galleries_activate');
         WC_Dynamic_Gallery_Functions::reset_products_galleries_activate();
     }
     if ((isset($_POST['bt_save_settings']) || isset($_POST['bt_reset_settings'])) && get_option('wc_dgallery_lite_clean_on_deletion') == 'no') {
         $uninstallable_plugins = (array) get_option('uninstall_plugins');
         unset($uninstallable_plugins[WOO_DYNAMIC_GALLERY_NAME]);
         update_option('uninstall_plugins', $uninstallable_plugins);
     }
 }
    public static function wc_dynamic_gallery_preview($request = '')
    {
        if (!is_user_logged_in() || !current_user_can('manage_options')) {
            die;
        }
        global $wc_dgallery_fonts_face;
        $request = $_REQUEST;
        /**
         * Single Product Image
         */
        $post = new stdClass();
        $current_db_version = get_option('woocommerce_db_version', null);
        $woo_a3_gallery_settings = $request;
        $lightbox_class = 'lightbox';
        $thumbs_list_class = '';
        $display_back_and_forward = 'true';
        $post->ID = rand(10, 10000);
        if (!isset($woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'width_type']) || $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'width_type'] == 'px') {
            $g_width = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_width_fixed'] . 'px';
            $g_height = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_height'];
        } else {
            $g_width = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_width_responsive'] . '%';
            $g_height = false;
            $max_height = 533;
            $width_of_max_height = 400;
            ?>
            <script type="text/javascript">
			(function($){
				$(function(){
					a3revWCDynamicGallery_<?php 
            echo $post->ID;
            ?>
 = {
		
						setHeightProportional: function () {
							var image_wrapper_width = $( '#gallery_<?php 
            echo $post->ID;
            ?>
' ).find('.a3dg-image-wrapper').width();
							var width_of_max_height = parseInt(<?php 
            echo $width_of_max_height;
            ?>
);
							var image_wrapper_height = parseInt(<?php 
            echo $max_height;
            ?>
);
							if( width_of_max_height > image_wrapper_width ) {
								var ratio = width_of_max_height / image_wrapper_width;
								image_wrapper_height = parseInt(<?php 
            echo $max_height;
            ?>
) / ratio;
							}
							$( '#gallery_<?php 
            echo $post->ID;
            ?>
' ).find('.a3dg-image-wrapper').css({ height: image_wrapper_height });
						}
					}
					
					a3revWCDynamicGallery_<?php 
            echo $post->ID;
            ?>
.setHeightProportional();
					
					$( window ).resize(function() {
						a3revWCDynamicGallery_<?php 
            echo $post->ID;
            ?>
.setHeightProportional();
					});
				});
	  		})(jQuery);
			</script>
            <?php 
        }
        $caption_font = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'caption_font'];
        $navbar_font = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'navbar_font'];
        $google_fonts = array($caption_font['face'], $navbar_font['face']);
        $wc_dgallery_fonts_face->generate_google_webfonts($google_fonts);
        ?>
        <div class="images" style="width:<?php 
        echo $g_width;
        ?>
;margin:30px auto;">
          <div class="product_gallery">
            <?php 
        $shop_thumbnail = wc_get_image_size('shop_thumbnail');
        $g_thumb_width = $shop_thumbnail['width'];
        $g_thumb_height = $shop_thumbnail['height'];
        $g_thumb_spacing = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_spacing'];
        if (isset($woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_show_type'])) {
            $thumb_show_type = 'slider';
        } else {
            $thumb_show_type = 'static';
        }
        $thumb_columns = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_columns'];
        if ('static' == $thumb_show_type) {
            $thumbs_list_class = 'a3dg-thumbs-static';
            $display_back_and_forward = 'false';
        }
        if (isset($woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_auto_start'])) {
            $g_auto = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_auto_start'];
        } else {
            $g_auto = 'false';
        }
        $g_speed = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_speed'];
        $g_effect = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_effect'];
        $g_animation_speed = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_animation_speed'];
        $bg_nav_color = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'bg_nav_color'];
        $bg_image_wrapper = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'bg_image_wrapper'];
        $border_image_wrapper_color = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'border_image_wrapper_color'];
        $product_gallery_bg_des = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_bg_des'];
        if (isset($woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_nav'])) {
            $product_gallery_nav = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_nav'];
        } else {
            $product_gallery_nav = 'no';
        }
        $transition_scroll_bar = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'transition_scroll_bar'];
        if (isset($woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'lazy_load_scroll'])) {
            $lazy_load_scroll = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'lazy_load_scroll'];
        } else {
            $lazy_load_scroll = 'no';
        }
        $navbar_height = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'navbar_height'];
        if ($product_gallery_nav == 'yes') {
            $display_ctrl = 'display:block !important;';
            $mg = $navbar_height;
            $ldm = $navbar_height;
        } else {
            $display_ctrl = 'display:none !important;';
            $mg = '0';
            $ldm = '0';
        }
        $popup_gallery = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'popup_gallery');
        $zoom_label = __('ZOOM +', 'woo_dgallery');
        if ($popup_gallery == 'deactivate') {
            $lightbox_class = '';
            $zoom_label = '';
        }
        if (isset($woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'enable_gallery_thumb'])) {
            $enable_gallery_thumb = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'enable_gallery_thumb'];
        } else {
            $enable_gallery_thumb = 'no';
        }
        $bg_des = WC_Dynamic_Gallery_Functions::html2rgb($product_gallery_bg_des, true);
        $des_background = str_replace('#', '', $product_gallery_bg_des);
        $thumb_border_color = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_border_color'];
        $thumb_current_border_color = $woo_a3_gallery_settings[WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_current_border_color'];
        ?>

			<script type='text/javascript'>
			/* <![CDATA[ */
			var a3_dgallery_arg = {"show_thumb":"<?php 
        echo $enable_gallery_thumb;
        ?>
","hide_one_thumb":"yes","thumb_show_type":"<?php 
        echo $thumb_show_type;
        ?>
","thumb_visible":"<?php 
        echo $thumb_columns;
        ?>
","thumb_spacing":"<?php 
        echo $g_thumb_spacing;
        ?>
"};
			/* ]]> */
			</script>

			<?php 
        echo '<style>
			#TB_window{width:auto !important;}
                .a3-dgallery {
						position:relative;
                }
				.a3-dgallery .a3dg-image-wrapper {
					background:#' . $bg_image_wrapper . ';
                    width: 99.3%;' . ($g_height != false ? 'height: ' . ($g_height - 2) . 'px;' : '') . 'margin: 0px;
                    position: relative;
                    overflow: hidden !important;
                    padding:0;
                    border:1px solid #' . $border_image_wrapper_color . ';
					z-index:8 !important;
                }
				.a3-dgallery .a3dg-image-wrapper .a3dg-image{width:100% !important;text-align:center;}
                .a3dg-image img{
                    
                }
                .a3-dgallery .a3dg-thumbs li{
                    margin-right: ' . $g_thumb_spacing . 'px !important;
                }';
        if ('static' == $thumb_show_type) {
            echo '.a3-dgallery .a3dg-thumbs li{
                    margin-bottom: ' . $g_thumb_spacing . 'px !important;
                }';
        }
        echo '
				/*Gallery*/
				.a3dg-image-wrapper{
					overflow:inherit !important;
				}
				
				.a3-dgallery .a3dg-controls {
					background: #' . $bg_nav_color . ' !important;
					border:1px solid #' . $bg_nav_color . ';
					color: #FFFFFF;
					font-size: 12px;
					height: 22px;
					margin-top: 20px !important;
					padding: 8px 2% !important;
					position: relative;
					width: 95.8%;
					-khtml-border-radius:5px;
					-webkit-border-radius: 5px;
					-moz-border-radius: 5px;
					border-radius: 5px;display:none;
				}
				
				.a3-dgallery .a3dg-info {
					float: right;
					font-size: 14px;
					position: relative;
					right: 8px;
					text-shadow: 1px 1px 1px #000000 !important;
					top: 1px !important;
				}
				.a3-dgallery .a3dg-nav .a3dg-thumbs{
					margin:7px 4% 0 !important;
				}
				.a3-dgallery .a3dg-thumbs .a3dg-thumb-list {
					margin-top: 0px !important;
				}
				.a3dg-thumb-list{
				}
				.a3dg-thumb-list li{
					background:none !important;
					padding-bottom:0 !important;
					padding-left:0 !important;
					padding-top:0 !important;
				}
				.a3-dgallery .a3dg-image-wrapper .a3dg-image-description {
					background: rgba(' . $bg_des . ',0.5);
					filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr="#88' . $des_background . '", EndColorStr="#88' . $des_background . '");
					bottom: ' . $mg . 'px !important;';
        echo $wc_dgallery_fonts_face->generate_font_css($caption_font);
        echo '
					left: 0;
					line-height: 1.4em;
					margin: 0 !important;
					padding:2% 2% 2% !important;
					position: absolute;
					text-align: left;
					width: 96.1% !important;
					z-index: 10;
					font-weight:normal;
				}
				.product_gallery .a3-dgallery .a3dg-image-wrapper {
					background: none repeat scroll 0 0 ' . $bg_image_wrapper . ';
					border: 1px solid ' . $border_image_wrapper_color . ' !important;
					padding-bottom:' . $mg . 'px;
				}';
        if ($lazy_load_scroll == 'yes') {
            echo '.a3-dgallery .lazy-load{
						background:' . $transition_scroll_bar . ' !important;' . ($g_height != false ? 'top:' . ($g_height + 9) . 'px !important;' : '') . 'opacity:1 !important;
						margin-top:' . $ldm . 'px !important;
					}';
        } else {
            echo '.a3-dgallery .lazy-load{display:none!important;}';
        }
        echo '
				.product_gallery .slide-ctrl, .product_gallery .icon_zoom {
					' . $display_ctrl . ';
					height: ' . ($navbar_height - 16) . 'px !important;
					line-height: ' . ($navbar_height - 16) . 'px !important;';
        echo $wc_dgallery_fonts_face->generate_font_css($navbar_font);
        echo '
				}
				.product_gallery .icon_zoom {
					background: ' . $bg_nav_color . ';
					border-right: 1px solid ' . $bg_nav_color . ';
					border-top: 1px solid ' . $border_image_wrapper_color . ';
				}
				.product_gallery .slide-ctrl {
					background:' . $bg_nav_color . ';
					border-left: 1px solid ' . $border_image_wrapper_color . ';
					border-top: 1px solid ' . $border_image_wrapper_color . ';
				}
				.product_gallery .slide-ctrl .a3dg-slideshow-stop-slide,.product_gallery .slide-ctrl .a3dg-slideshow-start-slide,.product_gallery .icon_zoom{
					line-height: ' . ($navbar_height - 16) . 'px !important;';
        echo $wc_dgallery_fonts_face->generate_font_css($navbar_font);
        echo '
				}
				.product_gallery .a3-dgallery .a3dg-thumbs li a {
					border:1px solid ' . $thumb_border_color . ' !important;
				}
				.a3-dgallery .a3dg-thumbs li a.a3dg-active {
					border: 1px solid ' . $thumb_current_border_color . ' !important;
				}';
        if ($enable_gallery_thumb == 'no') {
            echo '.a3dg-nav{display:none; height:1px;}.woocommerce .images { margin-bottom: 15px;}';
        }
        if ($product_gallery_nav == 'no') {
            echo '
				.a3dg-image-wrapper:hover .slide-ctrl{display: block !important;}
				.product_gallery .slide-ctrl {
					background: none repeat scroll 0 0 transparent;
					border: medium none;
					height: 50px !important;
					left: 41.5% !important;
					top: 38% !important;
					width: 50px !important;
				}';
            echo '.product_gallery .slide-ctrl .a3dg-slideshow-start-slide {background: url(' . WOO_DYNAMIC_GALLERY_JS_URL . '/mygallery/play.png) !important;height: 50px !important;text-indent: -999em !important; width: 50px !important;}';
            echo '.product_gallery .slide-ctrl .a3dg-slideshow-stop-slide {background: url(' . WOO_DYNAMIC_GALLERY_JS_URL . '/mygallery/pause.png) !important;height: 50px !important;text-indent: -999em !important; width: 50px !important;}';
        }
        if ($popup_gallery == 'deactivate') {
            echo '.a3-dgallery .a3dg-image-wrapper .a3dg-image img{cursor: default;} .a3-dgallery .icon_zoom{cursor: default;}';
        }
        echo '
			</style>';
        echo '<script type="text/javascript">
                jQuery(function() {
                    var settings_defaults_' . $post->ID . ' = { loader_image: "' . WOO_DYNAMIC_GALLERY_JS_URL . '/mygallery/loader.gif",
                        start_at_index: 0,
                        gallery_ID: "' . $post->ID . '",
						lightbox_class: "' . $lightbox_class . '",
                        description_wrapper: false,
                        thumb_opacity: 0.5,
                        animate_first_image: false,
                        animation_speed: ' . $g_animation_speed . '000,
                        width: false,
                        height: false,
                        display_next_and_prev: true,
                        display_back_and_forward: ' . $display_back_and_forward . ',
                        scroll_jump: 0,
                        slideshow: {
                            enable: true,
                            autostart: ' . $g_auto . ',
                            speed: ' . $g_speed . '000,
                            start_label: "' . __('START SLIDESHOW', 'woo_dgallery') . '",
                            stop_label: "' . __('STOP SLIDESHOW', 'woo_dgallery') . '",
							zoom_label: "' . $zoom_label . '",
                            stop_on_scroll: true,
                            countdown_prefix: "(",
                            countdown_sufix: ")",
                            onStart: false,
                            onStop: false
                        },
                        effect: "' . $g_effect . '", 
                        enable_keyboard_move: true,
                        cycle: true,
                        callbacks: {
                        init: false,
                        afterImageVisible: false,
                        beforeImageVisible: false
                    }
                };
                jQuery("#gallery_' . $post->ID . '").adGallery(settings_defaults_' . $post->ID . ');
            });
            </script>';
        echo '<div id="gallery_' . $post->ID . '" class="a3-dgallery" style="">
                <div class="a3dg-image-wrapper" style="width: 99.3%; ' . ($g_height != false ? 'height: ' . ($g_height - 2) . 'px;' : '') . '"></div>
                <div class="a3dg-controls"> </div>
                  <div class="a3dg-nav">
                    <div class="a3dg-thumbs ' . $thumbs_list_class . '">
                      <ul class="a3dg-thumb-list">';
        $url_demo_img = '/assets/js/mygallery/images/';
        $imgs = array($url_demo_img . 'image_1.jpg', $url_demo_img . 'image_2.jpg', $url_demo_img . 'image_3.jpg', $url_demo_img . 'image_4.jpg');
        $script_colorbox = '';
        $script_fancybox = '';
        if (!empty($imgs)) {
            $i = 0;
            $display = '';
            if (is_array($imgs) && count($imgs) > 0) {
                $script_colorbox .= '<script type="text/javascript">';
                $script_fancybox .= '<script type="text/javascript">';
                $script_colorbox .= '(function($){';
                $script_fancybox .= '(function($){';
                $script_colorbox .= '$(function(){';
                $script_fancybox .= '$(function(){';
                $script_colorbox .= '$(document).on("click", ".a3-dgallery .lightbox", function(ev) { if( $(this).attr("rel") == "gallery_' . $post->ID . '") {
								var idx = $(".a3dg-image img").attr("idx");';
                $script_fancybox .= '$(document).on("click", ".a3-dgallery .lightbox", function(ev) { if( $(this).attr("rel") == "gallery_' . $post->ID . '") {
								var idx = $(".a3dg-image img").attr("idx");';
                if (count($imgs) <= 1) {
                    $script_colorbox .= '$(".gallery_product_' . $post->ID . '").colorbox({open:true, maxWidth:"100%" });';
                    $script_fancybox .= '$.fancybox(';
                } else {
                    $script_colorbox .= '$(".gallery_product_' . $post->ID . '").colorbox({rel:"gallery_product_' . $post->ID . '", maxWidth:"100%" }); $(".gallery_product_' . $post->ID . '_"+idx).colorbox({open:true, maxWidth:"100%" });';
                    $script_fancybox .= '$.fancybox([';
                }
                $common = '';
                $idx = 0;
                foreach ($imgs as $item_thumb) {
                    $li_class = '';
                    if ('static' == $thumb_show_type) {
                        if ($idx % $thumb_columns == 0) {
                            $li_class = 'first_item';
                        } elseif ($idx % $thumb_columns + 1 == $thumb_columns) {
                            $li_class = 'last_item';
                        }
                    } else {
                        if ($idx == 0) {
                            $li_class = 'first_item';
                        } elseif ($idx == count($imgs) - 1) {
                            $li_class = 'last_item';
                        }
                    }
                    $image_attribute = getimagesize(WOO_DYNAMIC_GALLERY_DIR . $item_thumb);
                    $image_lager_default_url = WOO_DYNAMIC_GALLERY_URL . $item_thumb;
                    $thumb_height = $g_thumb_height;
                    $thumb_width = $g_thumb_width;
                    $width_old = $image_attribute[0];
                    $height_old = $image_attribute[1];
                    if ($width_old > $g_thumb_width || $height_old > $g_thumb_height) {
                        if ($height_old > $g_thumb_height && $g_thumb_height > 0) {
                            $factor = $height_old / $g_thumb_height;
                            $thumb_height = $g_thumb_height;
                            $thumb_width = $width_old / $factor;
                        }
                        if ($thumb_width > $g_thumb_width && $g_thumb_width > 0) {
                            $factor = $width_old / $g_thumb_width;
                            $thumb_height = $height_old / $factor;
                            $thumb_width = $g_thumb_width;
                        } elseif ($thumb_width == $g_thumb_width && $width_old > $g_thumb_width && $g_thumb_width > 0) {
                            $factor = $width_old / $g_thumb_width;
                            $thumb_height = $height_old / $factor;
                            $thumb_width = $g_thumb_width;
                        }
                    } else {
                        $thumb_height = $height_old;
                        $thumb_width = $width_old;
                    }
                    $img_description = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.';
                    echo '<li class="' . $li_class . '">';
                    echo '<a class="gallery_product_' . $post->ID . ' gallery_product_' . $post->ID . '_' . $idx . '" title="' . esc_attr($img_description) . '" rel="gallery_product_' . $post->ID . '" href="' . $image_lager_default_url . '">';
                    echo '<img
									org-sizes=""
									org-srcset=""
									sizes=""
									srcset=""
                                    idx="' . $idx . '"
                                    src="' . $image_lager_default_url . '"
                                    alt="' . esc_attr($img_description) . '"
                                    class="image' . $i . '"
                                    width="' . $thumb_width . '"
                                    height="' . $thumb_height . '">';
                    echo '</a>';
                    echo '</li>';
                    $img_description = esc_js($img_description);
                    if ($img_description != '') {
                        $script_fancybox .= $common . '{href:"' . $image_lager_default_url . '",title:"' . $img_description . '"}';
                    } else {
                        $script_fancybox .= $common . '{href:"' . $image_lager_default_url . '",title:""}';
                    }
                    $common = ',';
                    $i++;
                    $idx++;
                }
                //$.fancybox([ {href : 'img1.jpg', title : 'Title'}, {href : 'img2.jpg', title : 'Title'} ])
                if (count($imgs) <= 1) {
                    $script_fancybox .= ');';
                } else {
                    $script_fancybox .= '],{
        \'index\': idx
      });';
                }
                $script_colorbox .= 'ev.preventDefault();';
                $script_colorbox .= '} });';
                $script_fancybox .= '} });';
                $script_colorbox .= '});';
                $script_fancybox .= '});';
                $script_colorbox .= '})(jQuery);';
                $script_fancybox .= '})(jQuery);';
                $script_colorbox .= '</script>';
                $script_fancybox .= '</script>';
            }
        } else {
            $no_image_uri = WC_Dynamic_Gallery_Functions::get_no_image_uri();
            echo '<li> <a class="lightbox" rel="gallery_product_' . $post->ID . '" href="' . $no_image_uri . '"> <img src="' . $no_image_uri . '" class="image" alt=""> </a> </li>';
        }
        if ($popup_gallery == 'deactivate') {
            $script_colorbox = '';
            $script_fancybox = '';
        } else {
            if ($popup_gallery == 'colorbox') {
                echo $script_colorbox;
            } else {
                echo $script_fancybox;
            }
        }
        echo '</ul>
                        </div>
                      </div>
                    </div>';
        ?>
          </div>
        </div>
	<?php 
        die;
    }
    public static function wc_dynamic_gallery_display($product_id = 0)
    {
        /**
         * Single Product Image
         */
        global $post, $wc_dgallery_fonts_face;
        $display_back_and_forward = 'true';
        $no_image_uri = WC_Dynamic_Gallery_Functions::get_no_image_uri();
        if ($product_id < 1) {
            $product_id = $post->ID;
        }
        // Get gallery of this product
        $dgallery_ids = WC_Dynamic_Gallery_Functions::get_gallery_ids($product_id);
        if (!is_array($dgallery_ids)) {
            $dgallery_ids = array();
        }
        $main_dgallery = array();
        $ogrinal_product_id = $product_id;
        $product_id .= '_' . rand(100, 10000);
        $lightbox_class = 'lightbox';
        $thumbs_list_class = '';
        if (count($dgallery_ids) > 0) {
            // Assign image data into main gallery array
            foreach ($dgallery_ids as $img_id) {
                // Check if image id is existed on main gallery then just use it again for decrease query
                if (isset($main_dgallery[$img_id])) {
                    continue;
                }
                $image_data = get_post($img_id);
                $large_image_attribute = wp_get_attachment_image_src($img_id, 'large');
                $thumb_image_attribute = wp_get_attachment_image_src($img_id, 'shop_thumbnail');
                $alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
                $large_srcset = '';
                $large_sizes = '';
                $thumb_srcset = '';
                $thumb_sizes = '';
                if (function_exists('wp_get_attachment_image_srcset')) {
                    $large_srcset = wp_get_attachment_image_srcset($img_id, 'large');
                    $thumb_srcset = wp_get_attachment_image_srcset($img_id, 'shop_thumbnail');
                }
                if (function_exists('wp_get_attachment_image_sizes')) {
                    $large_sizes = wp_get_attachment_image_sizes($img_id, 'large');
                    $thumb_sizes = wp_get_attachment_image_sizes($img_id, 'shop_thumbnail');
                }
                $main_dgallery[$img_id] = array('caption_text' => $image_data->post_excerpt, 'alt_text' => $alt, 'thumb' => array('url' => $thumb_image_attribute[0], 'width' => $thumb_image_attribute[1], 'height' => $thumb_image_attribute[2], 'img_srcset' => $thumb_srcset, 'img_sizes' => $thumb_sizes), 'large' => array('url' => $large_image_attribute[0], 'width' => $large_image_attribute[1], 'height' => $large_image_attribute[2], 'img_srcset' => $large_srcset, 'img_sizes' => $large_sizes));
            }
        }
        ?>

		<div class="images gallery_container">
			<div class="product_gallery">
            <?php 
        $g_width = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_width_fixed') . 'px';
        $shop_thumbnail = wc_get_image_size('shop_thumbnail');
        $g_thumb_width = $shop_thumbnail['width'];
        $g_thumb_height = $shop_thumbnail['height'];
        $thumb_show_type = 'slider';
        $thumb_columns = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'thumb_columns', 3);
        if ('static' == $thumb_show_type) {
            $thumbs_list_class = 'a3dg-thumbs-static';
        }
        $g_auto = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_auto_start');
        $g_speed = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_speed');
        $g_effect = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_effect');
        $g_animation_speed = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'product_gallery_animation_speed');
        $popup_gallery = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'popup_gallery');
        $hide_thumb_1image = get_option(WOO_DYNAMIC_GALLERY_PREFIX . 'hide_thumb_1image');
        if ('static' == $thumb_show_type) {
            $display_back_and_forward = 'false';
        }
        $zoom_label = __('ZOOM +', 'woo_dgallery');
        if ('deactivate' == $popup_gallery) {
            $zoom_label = '';
            $lightbox_class = '';
        }
        $_upload_dir = wp_upload_dir();
        if (file_exists($_upload_dir['basedir'] . '/sass/woo_dynamic_gallery.min.css')) {
            echo '<link media="all" type="text/css" href="' . str_replace(array('http:', 'https:'), '', $_upload_dir['baseurl']) . '/sass/woo_dynamic_gallery.min.css?ver=' . WOO_DYNAMIC_GALLERY_VERSION . '" rel="stylesheet" />' . "\n";
        } else {
            include WOO_DYNAMIC_GALLERY_DIR . '/templates/customized_style.php';
        }
        echo '<style>';
        if ('yes' == $hide_thumb_1image && count($dgallery_ids) <= 1) {
            echo '#gallery_' . $product_id . ' .a3dg-nav{display:none;} .woocommerce #gallery_' . $product_id . ' .images { margin-bottom: 15px;}';
        }
        echo '
			</style>';
        echo '<script type ="text/javascript">
				jQuery(function() {
					var settings_defaults_' . $product_id . ' = { loader_image: "' . WOO_DYNAMIC_GALLERY_JS_URL . '/mygallery/loader.gif",
						start_at_index: 0,
						gallery_ID: "' . $product_id . '",
						lightbox_class: "' . $lightbox_class . '",
						description_wrapper: false,
						thumb_opacity: 0.5,
						animate_first_image: false,
						animation_speed: ' . $g_animation_speed . '000,
						width: false,
						height: false,
						display_next_and_prev: true,
						display_back_and_forward: ' . $display_back_and_forward . ',
						scroll_jump: 0,
						slideshow: {
							enable: true,
							autostart: ' . $g_auto . ',
							speed: ' . $g_speed . '000,
							start_label: "' . __('START SLIDESHOW', 'woo_dgallery') . '",
							stop_label: "' . __('STOP SLIDESHOW', 'woo_dgallery') . '",
							zoom_label: "' . $zoom_label . '",
							stop_on_scroll: true,
							countdown_prefix: "(",
							countdown_sufix: ")",
							onStart: false,
							onStop: false
						},
						effect: "' . $g_effect . '",
						enable_keyboard_move: true,
						cycle: true,
						callbacks: {
						init: false,
						afterImageVisible: false,
						beforeImageVisible: false
					}
				};
				jQuery("#gallery_' . $product_id . '").adGallery(settings_defaults_' . $product_id . ');
			});

            </script>';
        echo '<img style="width: 0px ! important; height: 0px ! important; display: none ! important; position: absolute;" src="' . WOO_DYNAMIC_GALLERY_IMAGES_URL . '/blank.gif">';
        echo '<div id="gallery_' . $product_id . '" class="a3-dgallery" style="width: ' . $g_width . ';">
				<div class="a3dg-image-wrapper"></div>
				<div class="a3dg-controls"> </div>
				<div class="a3dg-nav">
					<div class="a3dg-thumbs ' . $thumbs_list_class . '">
						<ul class="a3dg-thumb-list">';
        $script_colorbox = '';
        $script_fancybox = '';
        if (count($dgallery_ids) > 0) {
            $script_colorbox .= '<script type="text/javascript">';
            $script_fancybox .= '<script type="text/javascript">';
            $script_colorbox .= '(function($){';
            $script_fancybox .= '(function($){';
            $script_colorbox .= '$(function(){';
            $script_fancybox .= '$(function(){';
            $script_colorbox .= '$(document).on("click", ".a3-dgallery .lightbox", function(ev) { if( $(this).attr("rel") == "gallery_' . $product_id . '") {
								var idx = $("#gallery_' . $product_id . ' .a3dg-image img").attr("idx");';
            $script_fancybox .= '$(document).on("click", ".a3-dgallery .lightbox", function(ev) { if( $(this).attr("rel") == "gallery_' . $product_id . '") {
								var idx = $("#gallery_' . $product_id . ' .a3dg-image img").attr("idx");';
            if (count($dgallery_ids) <= 1) {
                $script_colorbox .= '$(".gallery_product_' . $product_id . '").colorbox({open:true, maxWidth:"100%" });';
                $script_fancybox .= '$.fancybox(';
            } else {
                $script_colorbox .= '$(".gallery_product_' . $product_id . '").colorbox({rel:"gallery_product_' . $product_id . '", maxWidth:"100%" }); $(".gallery_product_' . $product_id . '_"+idx).colorbox({open:true, maxWidth:"100%" });';
                $script_fancybox .= '$.fancybox([';
            }
            $common = '';
            $idx = 0;
            foreach ($dgallery_ids as $img_id) {
                if (!isset($main_dgallery[$img_id])) {
                    continue;
                }
                // Get image data from main gallery array
                $gallery_item = $main_dgallery[$img_id];
                $li_class = '';
                if ('static' == $thumb_show_type) {
                    if ($idx % $thumb_columns == 0) {
                        $li_class = 'first_item';
                    } elseif ($idx % $thumb_columns + 1 == $thumb_columns) {
                        $li_class = 'last_item';
                    }
                } else {
                    if ($idx == 0) {
                        $li_class = 'first_item';
                    } elseif ($idx == count($dgallery_ids) - 1) {
                        $li_class = 'last_item';
                    }
                }
                $image_large_url = $gallery_item['large']['url'];
                $image_thumb_url = $gallery_item['thumb']['url'];
                $thumb_height = $g_thumb_height;
                $thumb_width = $g_thumb_width;
                $width_old = $gallery_item['thumb']['width'];
                $height_old = $gallery_item['thumb']['height'];
                if ($width_old > $g_thumb_width || $height_old > $g_thumb_height) {
                    if ($height_old > $g_thumb_height && $g_thumb_height > 0) {
                        $factor = $height_old / $g_thumb_height;
                        $thumb_height = $g_thumb_height;
                        $thumb_width = $width_old / $factor;
                    }
                    if ($thumb_width > $g_thumb_width && $g_thumb_width > 0) {
                        $factor = $width_old / $g_thumb_width;
                        $thumb_height = $height_old / $factor;
                        $thumb_width = $g_thumb_width;
                    } elseif ($thumb_width == $g_thumb_width && $width_old > $g_thumb_width && $g_thumb_width > 0) {
                        $factor = $width_old / $g_thumb_width;
                        $thumb_height = $height_old / $factor;
                        $thumb_width = $g_thumb_width;
                    }
                } else {
                    $thumb_height = $height_old;
                    $thumb_width = $width_old;
                }
                echo '<li class="' . $li_class . '">';
                echo '<a alt="' . esc_attr($gallery_item['alt_text']) . '" class="gallery_product_' . $product_id . ' gallery_product_' . $product_id . '_' . $idx . '" title="' . esc_attr($gallery_item['caption_text']) . '" rel="gallery_product_' . $product_id . '" href="' . $image_large_url . '">';
                echo '<img
								org-width="' . esc_attr($gallery_item['large']['width']) . '"
								org-height="' . esc_attr($gallery_item['large']['height']) . '"
								org-sizes="' . esc_attr($gallery_item['large']['img_sizes']) . '"
								org-srcset="' . esc_attr($gallery_item['large']['img_srcset']) . '"
								sizes="' . esc_attr($gallery_item['thumb']['img_sizes']) . '"
								srcset="' . esc_attr($gallery_item['thumb']['img_srcset']) . '"
								idx="' . $idx . '"
								src="' . $image_thumb_url . '"
								alt="' . esc_attr($gallery_item['alt_text']) . '"
								data-caption="' . esc_attr($gallery_item['caption_text']) . '"
								class="image' . $idx . '"
								width="' . $thumb_width . '"
								height="' . $thumb_height . '">';
                echo '</a>';
                echo '</li>';
                if ('' != trim($gallery_item['caption_text'])) {
                    $script_fancybox .= $common . '{href:"' . $image_large_url . '",title:"' . esc_js($gallery_item['caption_text']) . '"}';
                } else {
                    $script_fancybox .= $common . '{href:"' . $image_large_url . '",title:""}';
                }
                $common = ',';
                $idx++;
            }
            if (count($dgallery_ids) <= 1) {
                $script_fancybox .= ');';
            } else {
                $script_fancybox .= '],{
    \'index\': idx
  });';
            }
            $script_colorbox .= 'ev.preventDefault();';
            $script_colorbox .= '} });';
            $script_fancybox .= '} });';
            $script_colorbox .= '});';
            $script_fancybox .= '});';
            $script_colorbox .= '})(jQuery);';
            $script_fancybox .= '})(jQuery);';
            $script_colorbox .= '</script>';
            $script_fancybox .= '</script>';
        } else {
            echo '<li>';
            echo '<a class="" rel="gallery_product_' . $product_id . '" href="' . $no_image_uri . '">';
            echo '<img org-width="" org-height="" sizes="" srcset="" src="' . $no_image_uri . '" class="image" alt="">';
            echo '</a>';
            echo '</li>';
        }
        if ('deactivate' == $popup_gallery) {
            $script_colorbox = '';
            $script_fancybox = '';
        } elseif ('colorbox' == $popup_gallery) {
            echo $script_colorbox;
        } else {
            echo $script_fancybox;
        }
        echo '</ul>
						</div>
					</div>
				</div>';
        ?>
			</div>
		</div>
	<?php 
    }