Slideshow with responsive Themes and/or different picture heights

Permalink 5 users found helpful
Hi There,

problem:

using a responsive layout with a slideshow creates bad effects, as the wrapper size is set to the true height of the picture, and not to the displayed size. Also the slideshow creates a background-image, which doesn't resize at all to fit into the page.
Example: using img {max-width: 100%) with an image sized 800x600 looks nice in the fullsized website, but on a mobile device the wrapper is still set to 600px height, but the displayed height is around 400px. so 200px of space are wasted.

solution:

modify the blocks/slideshow/view.php like this:

<?php  defined('C5_EXECUTE') or die("Access Denied."); ?>
<script type="text/javascript">
//<![CDATA[
var ccmSlideShowHelper<?php echo intval($bID)?> = {
   bID:<?php echo intval($bID)?>,
   imgNum:0,
   init:function(){
      this.displayWrap=$('#ccm-SlideshowBlock-display'+this.bID); 
      if(this.imgInfos.length==0){
         return false;
      }
      var maxHeight=0;
      for(var i=0;i<this.imgInfos.length;i++){
         this.addImg(i);
         if(maxHeight==0 || this.imgInfos[i].imgHeight > maxHeight)

sk01
 
primeone replied on at Permalink Reply
primeone
Hi!

I have been looking at a solution for this, and this works!

However, it feels almost animated when the image renders. Do you know why that is?
sk01 replied on at Permalink Reply
sk01
that's because it is animated. ;)

change the "500" to a lower value to speed up the animation:
$('#slideImgWrap0').parent().animate({height:imageHeight, queue: false},500);
or use another jQuery option to change it.
primeone replied on at Permalink Reply
primeone
Ok, that would explain a lot! Lol

But I can´t turn it of because I don´t know how. I just want it without the animation. Like it´s just loading like the normal slideshow. Is that difficult to change?
sk01 replied on at Permalink Reply
sk01
quick & dirty solution:

<?php  defined('C5_EXECUTE') or die("Access Denied."); ?>
<script type="text/javascript">
//<![CDATA[
var ccmSlideShowHelper<?php echo intval($bID)?> = {
   bID:<?php echo intval($bID)?>,
   imgNum:0,
   init:function(){
      this.displayWrap=$('#ccm-SlideshowBlock-display'+this.bID); 
      $('#ccm-SlideshowBlock-display'+this.bID).css('overflow','hidden');
      if(this.imgInfos.length==0){
         return false;
      }
      var maxHeight=0;
      for(var i=0;i<this.imgInfos.length;i++){
         this.addImg(i);
ripvanwinkle replied on at Permalink Reply
Works. MANY thanks.
ppisoban replied on at Permalink Reply
ppisoban
This worked so well, the only solution I found to the slideshow/responsive tricky problem. The only thing I would add is, don't forget to clear the cache! Mine didn't work till I did that and I wasted a bit of time trying to find another solution. Thanks very much.
sk01 replied on at Permalink Reply
sk01
you're welcome. just mark the discussion as helpful to get me some karma-points. ;)
ppisoban replied on at Permalink Reply
ppisoban
Already done! Great work!
cnrx replied on at Permalink Reply
cnrx
Excellent solution sk01! Thank you for sharing this!