joomla - External image blocks too slow

halftone

Joined: 2005-09-29
Posts: 22
Posted: Sat, 2005-10-22 12:45

Hi,

I'm displaying a set of 5 random images within a homemade Joomla template using the following code:-

    <div id="randomphoto1" style="position:absolute; width:150px; height:150px; z-index:1; left: 620px; top: 5px;" align="center" class="headerrandomimg">
		<?php @readfile('http://www.domain.com/joomla/index.php?option=com_gallery2&Itemid=26&g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none&maxsize=100'); ?> 
	</div>    
	<div id="randomphoto2" style="position:absolute; width:150px; height:150px; z-index:2; left: 720px; top: 10px;" align="center" class="headerrandomimg">
		<?php @readfile('http://www.domain.com/joomla/index.php?option=com_gallery2&Itemid=26&g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none&maxsize=100'); ?> 
	</div>    
	<div id="randomphoto3" style="position:absolute; width:150px; height:150px; z-index:3; left: 820px; top: 15px;" align="center" class="headerrandomimg">
		<?php @readfile('http://www.domain.com/joomla/index.php?option=com_gallery2&Itemid=26&g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none&maxsize=100'); ?> 
	</div>    
	<div id="randomphoto4" style="position:absolute; width:150px; height:150px; z-index:4; left: 920px; top: 0px;" align="center" class="headerrandomimg">
		<?php @readfile('http://www.domain.com/joomla/index.php?option=com_gallery2&Itemid=26&g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none&maxsize=100'); ?> 
	</div>
	<div id="randomphoto5" style="position:absolute; width:150px; height:150px; z-index:5; left: 1020px; top: 20px;" align="center" class="headerrandomimg">
		<?php @readfile('http://www.domain.com/joomla/index.php?option=com_gallery2&Itemid=26&g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none&maxsize=100'); ?> 
       </div>
 

Well, it works and looks how I want it to, 5 overlapping images - apart from the fact that the 'maxsize=100' appears not to work and I get my standard 150px thumbnails but I can live with that. However, at least on this slow development localhost machine, it is agonisingly slow. This section of the page takes 6-8 secs to build, the rest of the page typically ~0.1sec, according to timer code I've put into the template. Clearly this is a bit of a showstopper.

Can anyone who is PHP literate think of a way of speeding this up a lot? All thumbnails are pre-built, ie created at upload, not first view. BTW, removing the 'maxsize=100' parameter makes no difference at all.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-10-22 13:31

use the GalleryEmbed::getImageBlock method.

also you could get 5 images at once with blocks=randomImage|randomImage|randomImage|randomImage|randomImage

http://codex.gallery2.org/index.php/Gallery2:GalleryEmbed:getImageBlock

 
halftone

Joined: 2005-09-29
Posts: 22
Posted: Sat, 2005-10-22 16:07

Thanks for that - I didn't know it existed :-)

Having played with it for 20minutes (I assume I copy the code into the template HTML?) I am getting no output from this, and the rest of the page is going missing too. I expect I have paths wrong as usual for '/gallery2/embed.php' and 'embedpath' => '/gallery2/'. My site is arranged (webroot)/gallery2 and (webroot)/joomla, so I thought '/gallery2/embed.php' should be correct for the first, and '../gallery2' for the second, but I have tried lots of different permutations. However, I'm running Apache on XP here, and a few com_gallery paths have to be stated as full DOS paths, eg F:\\www\\webroot\\gallery2 so any guidance would be most welcome.

Second question is : if I pipe all 5 images, how do I define the HTML (div layers in this case) that I want to control their layout? "print $bodyhtml;" presumably will return something like "<img src..1><img src..2><img src 3> etc" so can only be formatted as a single block of 5 images, rather than 5 individual ones?

Regards
Tony Sleep

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-10-22 18:14
Quote:
Having played with it for 20minutes (I assume I copy the code into the template HTML?)

what, GalleryEmbed::getImageBlock ? no, GalleryEmbed::getImageBlock needs to be used in a php file.

 
halftone

Joined: 2005-09-29
Posts: 22
Posted: Sat, 2005-10-22 22:04

Sorry, I meant : I am embedding the code in a Joomla template (index.php). Is that wrong? What should I be doing with it? I am sure this is all obvious to someone who knows what they are doing, but I am new to all of this.

Regards
Tony Sleep

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-10-23 01:52

i guess you should just use the joomla h2 imageblock component / module and not edit any templates.

 
halftone

Joined: 2005-09-29
Posts: 22
Posted: Sun, 2005-10-23 13:16

The Joomla RandomImage module, pointed at G2 thumbnails? I can't, it won't respect G2 permissions. I'll persevere with this GalleryEmbed::getImageBlock PHP and try and figure out where I'm being stupid.

Regards
Tony Sleep