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:
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)
Viewing 15 lines of 91 lines. View entire code block.
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.
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.
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?
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?
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);
Viewing 15 lines of 92 lines. View entire code block.
Works. MANY thanks.
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.
you're welcome. just mark the discussion as helpful to get me some karma-points. ;)
Already done! Great work!
Excellent solution sk01! Thank you for sharing this!
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?