Jump to content

Need simple help with fix


bgbs

Recommended Posts

 

With this script below the 6 pics appear in one row, I would like them to appear in two rows, so three pics in each row and I dont know how to do that.

 

Any help would be appreciated

 

Thanks ahead of time

Ben

 

<?php

$tags = "sea, sand, caribe, sunshine";

$imageNumber = 6;

 

 

function getFlickrRSS(){

global $tags, $ids;

 

$url = "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=".$tags;

 

if ($fp = fopen($url, 'r')) {

$content = '';

 

while ($line = fread($fp, 1024)) {

$content .= $line;

}

}

 

return $content;

}

 

function getImages($rssContent){

global $imageNumber;

$before = '<media:thumbnail url="';

$after = '"';

$imageList = array();

 

$oldPos = 0;

$startPos=0;

 

do {

$oldPos = $startPos;

$startPos = strpos($rssContent,$before,$startPos) + strlen($before);

$endPos = strpos($rssContent,$after,$startPos);

$imageList[] = substr($rssContent,$startPos,$endPos-$startPos);

} while (($startPos > $oldPos) && (sizeof($imageList)<$imageNumber));

 

return $imageList;

}

 

$content = getFlickrRSS();

$imageList = getImages($content);

 

?>

Link to comment
https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/
Share on other sites

for ($x = 0; $x < sizeof($imageList); $x++) {
    if (($x%(ceil($imageNumber/2)) == 0) && ($x !== 0)) {
       echo "<br>";
    }
    echo "<img src='$imageList[$x]'>";
}

 

That is going to be the simple version. Because of the ceil() function, you can also change the amount of images you want to use and it will always display 2 rows and if it's an uneven amount, the 2nd row will have the missing slot.

Can you tell me exactly where I stick this code?

 

for ($x = 0; $x < sizeof($imageList); $x++) {
    if (($x%(ceil($imageNumber/2)) == 0) && ($x !== 0)) {
       echo "<br>";
    }
    echo "<img src='$imageList[$x]'>";
}

 

That is going to be the simple version. Because of the ceil() function, you can also change the amount of images you want to use and it will always display 2 rows and if it's an uneven amount, the 2nd row will have the missing slot.

ok cool that worked :)  Thanks man.

 

I had couple of more questions if you have time helping.

 

Originally I wanted the script to show only my flickr gallery pics from a particular set.

Not from tags, like it is doing right now. 

 

The user path and ID is "http://www.flickr.com/photos/25721203@N05/"

and set is  "warren"

 

And the other thing I wanted the script to do is make the pictures clickable so that when you click on them it takes you to the flickr page to view your picture.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.