TinyPortal

Development => Block Codes => Topic started by: chulian1819@gmail.com on May 03, 2008, 04:31:49 PM

Title: Gallery block using imageshack as server
Post by: chulian1819@gmail.com on May 03, 2008, 04:31:49 PM

Because my gallery is using too much bandwith and space, I work arround a "recent gallery images" block using imageshack as the server and its  remote RSS to show the last images added in a forum block:


//cofiguration

$rows=2;  //rows of the block
$colums=4; //colums of the block
$url="http://rss.imageshack.us/user/hcl404/rss/"; //where to find the recent images

//end configuration

function getFile($url,$timeout=0) {
# use CURL library to fetch remote file
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
if ( curl_getinfo($ch,CURLINFO_HTTP_CODE) !== 200 ) {
return('Bad Data File '.$url);
} else {
return $file_contents;
}
}


$xml=simplexml_load_string(getFile($url,10));
$channel=$xml->channel->item;       
$k=0;
echo "<table align='center'>";
for ($i=0;$i<$rows;$i++){
echo"<tr align='center'>";
for($j=0;$j<$colums;$j++){
echo "<td align='center'>";
echo $channel[$k]->description;   
$k++;
echo "</td>";
}
echo"</tr>";
}
echo "</table>";



just create an acount at http://imageshack.us/ and if you want, make it public for your forum members.

Then go to your profile at imageshack  and you will see the RSS of your images and use as the url parameter in the block, example:

$url="http://rss.imageshack.us/user/myuserlogin/rss/


hope you like it, if you have a low budget in hosting this will do the trick ;)
Title: Re: Gallery block using imageshack as server
Post by: Zetan on May 03, 2008, 04:33:32 PM
Nice idea, one we use.. we use Photobucket instead. I'll have to look into RSS for Photobucket.
Title: Re: Gallery block using imageshack as server
Post by: chulian1819@gmail.com on May 03, 2008, 07:19:33 PM
do you know where i can fid it?  i search the forum but didnt find anything like it
Title: Re: Gallery block using imageshack as server
Post by: Zetan on May 03, 2008, 07:37:27 PM
Quote from: chulian on May 03, 2008, 07:19:33 PM
do you know where i can fid it?  i search the forum but didnt find anything like it

Find what?
Title: Re: Gallery block using imageshack as server
Post by: Smoky on May 03, 2008, 07:42:53 PM
nice chulian, will have to try this  :D thanks!!
Title: Re: Gallery block using imageshack as server
Post by: chulian1819@gmail.com on May 04, 2008, 02:53:16 PM
thanks smoky, hope it works, any improves please share it here  ;)

Quote from: ZTN on May 03, 2008, 07:37:27 PM
Quote from: chulian on May 03, 2008, 07:19:33 PM
do you know where i can fid it?  i search the forum but didnt find anything like it

Find what?
the code for the one you use with photobucket

thanks
Title: Re: Gallery block using imageshack as server
Post by: Zetan on May 04, 2008, 02:58:18 PM
lol, I said I'd look into it.. I've never tried. But I just checked and they do have RSS feeds.

http://s150.photobucket.com/albums/s91/LABRADIO/

If you scroll to the very bottom, you'll find the feeds.
Title: Re: Gallery block using imageshack as server
Post by: chulian1819@gmail.com on May 04, 2008, 06:22:28 PM
I also tried with photobuket but the rss feed is too  big so mite lag the loading of the block, anyway i think  the script might needs some minor changes (or none, rss is a standar) to use photobucket RSS, so hava nice coding it ;)  be waiting the results
Title: Re: Gallery block using imageshack as server
Post by: alving on May 22, 2008, 02:06:42 PM
nice code!  how do you determine the number of images to be displayed?

opppsss.. ignore that question.. stupid me!  :laugh: