• Hi there!

    I was hoping to get a solution to this frustrating problem:
    I am loading 100+ images to be used in a gallery. The gallery plugin is a heavily modified soliloquy_lite. I load all the images into a php array and then through a json/query-based script I load the images into the galleria instance.

    However, creating the php array takes very long and slows down the loading of the page to more than 40 seconds even though its only creating an array at this point and not loading the actual images (this is hosted on an medium size amazon ec2 server with 2gb dedicated ram – not shared)! Here’s the code that loads the images data into the array:

    global $wp;
    global $wp_query;
    
    //create empty array container
    $gallery = array();
    
    //loop through all images in the gallery - upto 200 images here!
    foreach ($images as $image) {
    	$thumb = wp_get_attachment_image_src( $image['id'], 'event-list', true );
    	$full = wp_get_attachment_image_src( $image['id'], 'event-fixedshow', true );
    
    	//create a json block in the array to send back for processing
    	$gallery[] = "{
    		        thumb: '".$thumb[0]."',
    		        image: '".$full[0]."',
    		        title: '".$image['title']."',
    				},";
    
    }
    // Return the $gallery variable to be output by Soliloquy.
    return $gallery;

    So is there way to speed up the image loading by optimizing the wp_get_attachment_image_src function that seems to be the reason for this slowdown?

    Thanks for all the help!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Speeding up loading of 100 images on a post page’ is closed to new replies.