I have a plugin for joomla
which loads image icons from a folder
and then onClick shows a shadowboxed enlarged version
of the same image with description
below. I have custom hacked to display the download hi-res / print / add to facebook / add to twitter and send link via email.
At first I had some problems with the long urls
this code generates on the fly which could not be added to Facebook or Twitter. So I used a bit.ly api query script
which generates short URLs on the fly
for each image in each gallery. Everything works fine but there is only one problem
. Everytime I load a gallery page (I have several different gallery pages in a section) it takes a real long time for the page icons to load
(without the bit.ly script it loads instantaneously
). I believe that somehow my code asks bit.ly to send all the shortened URLs immediately and until it receives all of them it does not show my icons. Once the icons load everything works fast again. Also if I immediately reload a page after all its icons have already loaded, it makes me wait a real long time all over again.
Perhaps the solution could be that somewhere in my code I should do this:
1) for each session for each gallery that loads create an array (per gallery) on the fly and in each array save all the urls that it generates right at the start of the code
2) if I reload a gallery whose array exists already and is already full, I need it to bypass the part where it consults bit.ly and load the gallery right away
3) create a graphic preloader which keeps the end user occupied while the array is populated and icons are loaded per gallery
Could anyone please help me modify my code to do this?
The bit.ly specific code is here (you will find it at the start of my sige.php file which I am attaching here - this file runs the gallery code and contains the below code too):
function make_bitly_url($url,$login,$appkey,$format = 'xml',$version = '2.0.1')
//create the URL
$bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;
//get the url
//could also use cURL here
$response = file_get_contents($bitly);
//parse depending on desired format
if(strtolower($format) == 'json')
$json = @json_decode($response,true);
$xml = simplexml_load_string($response);
//and later on in my php I call this code via:
$url = ($mosConfig_live_site."/plugins/content/sige/plugin_sige/socialshare.php?img=".$mosConfig_live_site.$rootfolder.$_images_dir_."/Midsize/".$images[$a]['filename']."&name=".$imagename);
$u = make_bitly_url($url,'badwolfff','R_f650e553b78bb0569fc67dbc16a5de7c','json');
Also I am attaching the original Sige plugin for Joomla 1.6 download from their own website.
Alternatively you could download it from their site:
Sige Plugin for Joomla! 1.6
You may test the working of my plugin on my test/debug site:
(click on the link "SOLUZIONI D'ARREDO" at the top and then select the different gallery categories from the large buttons on the left in that section.
thanks in advance