Photo Collage [PHP]


<?php if (!empty($entry['photos'])) {
?>
<div class="crispbx">
    <div class="crispcont1">

        <!-- <p> -->
        <?php 
            // echo "string";
            $i = 0;
            if (count($entry['photos']) <= 9) {
                $linhas = floor(count($entry['photos']) / 3);
                $resto = count($entry['photos']) % 3;

                $tam1h = '143px';
                $tam2h = '216.5px';
                $tam3h = '436px';
                                                            
                $tam1w = '32.8%';
                $tam2w = '49.2%';
                $tam3w = '99.1%';
                
            }
            $photoDiv .= '<div class="wall_photoboard">';
            $i = 1;
            foreach ($entry['photos'] as $path) {

                if ($i <= ($linhas * 3)) {
                    // $tamAtual = $tam1;

                    $tamAtual = $tam1w;
                    $tamAtualh = $tam1h;   

                } else {
                    if ($resto == 2) {
                        // $tamAtual = $tam2;

                        $tamAtual = $tam2w;
                        $tamAtualh = $tam2h;

                    } else 
                        // $tamAtual = $tam3;

                        $tamAtual = $tam3w;
                        $tamAtualh = $tam3h;

                }

                $margin = 'margin: 2px 0 0 2px';
                if (count($entry['photos']) == 1) {
                    $margin = 'margin: 0';
                    $tamAtualh = '100%';
                    $tamAtual = '100%';
                }
                $photoDiv .= '<a class="mid2wall" href="photo_detail.php?id=' . $path['id'] . '" ><img  style="width: ' . $tamAtual . '; height: ' . $tamAtualh . '; border-radius:px;' . $margin .';border:1px solid #ccc !important;"  src="uploads/' . $path['file'] . '"/></a>';
                $i++;
                if ($i >= 9 && count($entry['photos']) > 9) {
                    $photoDiv .= ' and ' . (count($entry['photos']) - 9) . ' more photos';
                    break;
                }

            }
            $photoDiv .= '</div>';

            echo $photoDiv;

            $photoDiv = '';

         ?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s