vvvmax / unitegallery

Unite Gallery - Responsive jQuery Image and Video Gallery Plugin. Aim to be the best gallery on the web on it's kind. See demo here:
http://unitegallery.net
MIT License
531 stars 158 forks source link

How to disable the repetition of the images in the carousel in a gallery with few pictures #185

Open lockerbleiben opened 6 years ago

lockerbleiben commented 6 years ago

Hey there, I´m using the carousel gallery. Some gallerys have few images but the width of the gallery is > 700px. So the images get repeated. I want to ask, how to disable this.

lockerbleiben commented 6 years ago

"Schweigen im Walde" :(

I made little dirty workaround for this issue

<? 
$number_of_images=0;
// this fills my array of images & increases $number_of_images
while([...])
{
    // Fill an array of images, whatever
    $number_of_images++;
}

/* reduce witdh of gallery if number of images is less than e.g. 6 */
// if $number_of_images ist smaller than 6, than fill style attribut max-width
// 160 is the estimated witdh of each image + margin/padding (adjust for your needs)
if($number_of_images<6) $max_width=' max-width:'.($i*160).'px;';

// surround div.gallery with a  parent div, which gets the max-width if needed.
    $out.='
<div style="margin:0 auto;'.$max_width.'">
        <div id="gallery">'.$caroussel_images.'</div>
</div>';