Home Forums WoodMart support forum Images Gallery not working

Images Gallery not working

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #105196

    estudiocrown
    Participant

    Hi,

    i’m having some trouble with the element “Images Gallery”. It was working just fine, I think the problem started last time I updated de theme.

    I’ve one page with two galleries in it, and when I clik an image to see it in lightbox mode, large images are not showing.

    Any help?
    Thank you,

    Attachments:
    You must be logged in to view attached files.
    #105209

    Artem Temos
    Keymaster

    Hello,

    Could you please disable all plugins that are not related to our theme and provide us your admin access so we can check it?

    Thank you in advance

    #105354

    estudiocrown
    Participant

    Hi,
    My admin access is in private content.

    #105415

    Artem Temos
    Keymaster

    Please, send us your FTP access as well.

    #105579

    estudiocrown
    Participant

    Sorry! I forgot to send you FTP access…

    #105627

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file

    function woodmart_getimgsize( $url, $referer = '' ) {
    	// Set headers    
    	$headers = array( 'Range: bytes=0-131072' );    
    	if ( !empty( $referer ) ) { array_push( $headers, 'Referer: ' . $referer ); }
    
    	// Get remote image
    	$ch = curl_init();
    	curl_setopt( $ch, CURLOPT_URL, $url );
    	curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    	curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
    	$data = curl_exec( $ch );
    	$http_status = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
    	$curl_errno = curl_errno( $ch );
    	curl_close( $ch );
    
    	// Get network stauts
    	if ( $http_status != 200 ) {
    	echo 'HTTP Status[' . $http_status . '] Errno [' . $curl_errno . ']';
    	return [0,0];
    	}
    
    	// Process image
    	$image = imagecreatefromstring( $data );
    	$dims = [ imagesx( $image ), imagesy( $image ) ];
    	imagedestroy($image);
    
    	return $dims;
    }
    function woodmart_images_gallery_shortcode($atts) {
    		$output = $class = $gallery_classes = $gallery_item_classes = $owl_atts = '';
    
    		$parsed_atts = shortcode_atts( array_merge( woodmart_get_owl_atts(), array(
    			'ids'        => '',
    			'images'     => '',
    			'columns'    => 3,
    			'size'       => '',
    			'img_size'   => 'medium',
    			'link'       => '',
    			'spacing' 	 => 30,
    			'on_click'   => 'lightbox',
    			'target_blank' => false,
    			'custom_links' => '',
    			'view'		 => 'grid',
    			'caption'    => false,
    			'speed' => '5000',
    			'autoplay' => 'no',
    			'lazy_loading' => 'no',
    			'scroll_carousel_init' => 'no',
    			'css_animation' => 'none',
    			'el_class' 	 => ''
    		) ), $atts );
    
    		extract( $parsed_atts );
    
    		// Override standard wordpress gallery shortcodes
    
    		if ( ! empty( $atts['ids'] ) ) {
    			$atts['images'] = $atts['ids'];
    		}
    
    		if ( ! empty( $atts['size'] ) ) {
    			$atts['img_size'] = $atts['size'];
    		}
    
    		extract( $atts );
    
    		$carousel_id = 'gallery_' . rand(100,999);
    
    		$images = explode(',', $images);
    
    		$class .= $el_class ? ' ' . $el_class : '';
    		$class .= ' view-' . $view;
    		$class .= woodmart_get_css_animation( $css_animation );
    
    		if ( 'lightbox' === $on_click ) {
    			$class .= ' photoswipe-images';
    			woodmart_enqueue_script( 'woodmart-photoswipe' );
    		}
    
    		if ( 'links' === $on_click && function_exists( 'vc_value_from_safe' ) ) {
    			$custom_links = vc_value_from_safe( $custom_links );
    			$custom_links = explode( ',', $custom_links );
    		}
    
    		if ( $view == 'carousel' ){
    			$custom_sizes = apply_filters( 'woodmart_images_gallery_shortcode_custom_sizes', false );
    			
    			$parsed_atts['carousel_id'] = $carousel_id;
    			$parsed_atts['custom_sizes'] = $custom_sizes;
    
    			$owl_atts = woodmart_get_owl_attributes( $parsed_atts );
    			$gallery_classes .= ' owl-carousel ' . woodmart_owl_items_per_slide( $slides_per_view, array(), false, false, $custom_sizes );
    			$class .= ' woodmart-carousel-spacing-' . $spacing;
    			$class .= ' woodmart-carousel-container';
    
    			if ( $scroll_carousel_init == 'yes' ) {
    				$class .= ' scroll-init';
    			}
    
    			if ( woodmart_get_opt( 'disable_owl_mobile_devices' ) ) {
    				$class .= ' disable-owl-mobile';
    			}
    		} 
    
    		if ( $view == 'grid' || $view == 'masonry' ){
    			$gallery_classes .= ' row';
    			$gallery_classes .= ' woodmart-spacing-' . $spacing;
    			$gallery_item_classes .= woodmart_get_grid_el_class( 0, $columns );
    		}
    
    		if ( $lazy_loading == 'yes' ) {
    			woodmart_lazy_loading_init( true );
    		}
    
    		ob_start(); ?>
    			<div id="<?php echo esc_attr( $carousel_id ); ?>" class="woodmart-images-gallery<?php echo esc_attr( $class ); ?>" <?php echo ( $owl_atts ); ?>>
    				<div class="gallery-images<?php echo esc_attr( $gallery_classes ); ?>">
    					<?php if ( count($images) > 0 ): ?>
    						<?php $i=0; foreach ($images as $img_id):
    							$i++;
    							$attachment = get_post( $img_id );
    							$title = trim( strip_tags( $attachment->post_title ) );
    							$img = '';
    							if ( function_exists( 'wpb_getImageBySize' ) ) {
    								$img = wpb_getImageBySize( array( 'attach_id' => $img_id, 'thumb_size' => $img_size, 'class' => 'woodmart-gallery-image image-' . $i ) );
    							}
    
    							$link = wp_get_attachment_image_url( $img_id, 'full' );
    							$image_sizes        = woodmart_getimgsize( $link );
    
    							if( 'links' === $on_click ) {
    								$link = (isset( $custom_links[$i-1] ) ? $custom_links[$i-1] : '' );
    							}
    
    							?>
    							<div class="woodmart-gallery-item<?php echo esc_attr( $gallery_item_classes ); ?>">
    								<?php if ( $on_click != 'none' ): ?>
    									<a href="<?php echo esc_url( $link ); ?>" data-index="<?php echo esc_attr( $i ); ?>" data-width="<?php echo esc_attr( $image_sizes[0] ); ?>" data-height="<?php echo esc_attr( $image_sizes[1] ); ?>" <?php if( $target_blank ): ?>target="_blank"<?php endif; ?> <?php if( $caption ): ?>title="<?php echo esc_attr( $title ); ?>"<?php endif; ?>>
    								<?php endif ?>
    								
    								<?php if ( isset( $img['thumbnail'] ) ): ?>
    									<?php echo $img['thumbnail']; ?>
    								<?php endif; ?>
    								
    								<?php if ( $on_click != 'none' ): ?>
    									</a>
    								<?php endif ?>
    							</div>
    						<?php endforeach ?>
    					<?php endif ?>
    				</div>
    			</div>
    			<?php if ( $view == 'masonry' ): 
    				woodmart_enqueue_script( 'isotope' );
    				woodmart_enqueue_script( 'woodmart-packery-mode' );
    				
    				wp_add_inline_script('woodmart-theme', 'jQuery( document ).ready(function( $ ) {
    	                if (typeof($.fn.isotope) == "undefined" || typeof($.fn.imagesLoaded) == "undefined") return;
    	                var $container = $(".view-masonry .gallery-images");
    
    	                // initialize Masonry after all images have loaded
    	                $container.imagesLoaded(function() {
    	                    $container.isotope({
    	                        gutter: 0,
    	                        isOriginLeft: ! $("body").hasClass("rtl"),
    	                        itemSelector: ".woodmart-gallery-item"
    	                    });
    	                });
    				});', 'after');
    
    			elseif ( $view == 'justified' ): 
    				woodmart_enqueue_script( 'woodmart-justifiedGallery' );
    				
    				wp_add_inline_script('woodmart-theme', 'jQuery( document ).ready(function( $ ) {
    					$("#' . esc_js( $carousel_id ) . ' .gallery-images").justifiedGallery({
    						margins: 1
    					});
    				});', 'after');
    
    			endif ?>
    		<?php
    		$output = ob_get_contents();
    		ob_end_clean();
    		
    		if ( $lazy_loading == 'yes' ) {
    			woodmart_lazy_loading_deinit();
    		}
    
    		return $output;
    		
    	}
    	add_shortcode( 'woodmart_gallery', 'woodmart_images_gallery_shortcode' );
    #105809

    estudiocrown
    Participant

    Hi! I added de code to my functions.php but it gave me an HTTP ERROR 500

    I deactivated the child theme while you help me fixing this…

    Thank you!

    Attachments:
    You must be logged in to view attached files.
    #105811

    Artem Temos
    Keymaster

    We have copied the code for you. Please, check how it works now.

    #105830

    estudiocrown
    Participant

    Perfect! Thank you so much…

    #105831

    Artem Temos
    Keymaster

    You are welcome.

Viewing 10 posts - 1 through 10 (of 10 total)