Jump to content

Recommended Posts

Hello,

Once again I come to the PHP Freaks community for help.  I have spent serveral weeks trying to figure out how to do this. Attached below is code for a function that outputs images in a row. However I am tring to find a way so that it would output 5 images and then drop a line and continue to do this untill all the images have been displayed.  The variable which the output is stored in is named $out (towards the bottom).  The variable $thumb_row is the total number of images that are allowed to be displayed.  Here is an illustration of what I am trying to do the X is an image.

 

XXXXX

XXXXX

XXXXX

XXXXX

 

 

Thank you,

Grodo

 

function my_filmstrip($thumbnail_dir, &$template, $a_images, $currentPic, $thumb_row, $path_to_images) {
    global $path;
    global $auto_url;

    // get size of $a_images array...
    $number_pics = count($a_images);

    // do a little error checking...
    if ($currentPic > $number_pics) $currentPic = 0;
    if ($currentPic < 0) $currentPic = 0;
    if ($thumb_row < 0) $thumb_row = 1;
    if ($thumb_row > $number_pics) $thumb_row = $number_pics;

    if ($currentPic >= $thumb_row) {
        $start = $currentPic - $thumb_row + 1;
    }
    else {
        $start = 0;
    }

    $out = '';
    for ($x = $start; $x < ($start + $thumb_row); $x++ ) {
        $item = preg_split('/;/', rtrim($a_images[$x]), 2);
        $class = $x == $currentPic ? 'thumbnail_center' : 'thumbnail';
	if ($number_pics > 4)

        $out .= "\n<style type='text/css'>.img{opacity:1;filter:alpha(opacity=100)}a:hover img{filter:xray}</style><a href='$path?directory=$path_to_images$auto_url&currentPic=$x' class='thumbnail'><img src='$path_to_images/$thumbnail_dir/".$item[0]."' class='$class'></a>";

}

    $template = str_replace("<THUMBNAIL_ROW>",$out,$template);
}

Link to comment
https://forums.phpfreaks.com/topic/71452-solved-displaying-5-images-in-a-row/
Share on other sites

I have read over through the post but im still confused on how to input that into a variable....  This is what i came up with

	$i = 0;
	if ($i == 0)
		echo "<tr>";
                         echo "Image Goes Here"
	if (++$i == $max_imagerow) {
		echo "</tr>";
		$i=0;
	}

 

what would be the best way to put it into one.

My new code but still no luck someone please help

   for ($x = $start; $x < ($start + $thumb_row); $x++ ) {
        $item = preg_split('/;/', rtrim($a_images[$x]), 2);
        $class = $x == $currentPic ? 'thumbnail_center' : 'thumbnail';
	$out .= "\n<style type='text/css'>.img{opacity:1;filter:alpha(opacity=100)}
	a:hover img{filter:xray}</style>
	<a href='$path?directory=$path_to_images$auto_url&currentPic=$x' class='thumbnail'>
	<img src='$path_to_images/$thumbnail_dir/".$item[0]."' class='$class'></a>";
	for ($check =0; $check < $thumb_row; $check++) {
	if ($check=4)
		$out = $out + "<br>";
	if ($check=
		$out = $out + "<br>";
	}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.