making all images responsive using jQuery

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mansour
User
Posts: 282

making all images responsive using jQuery

Post by mansour »

Hi all,
I'm using PHPmaker 2019, This great product shows multiple images as an image gallery. The problem is that these images are NOT responsive. I checked the codes. It seems the gallery uses the "cboxPhoto" class. How to make all images responsive using jQuery?

Any idea?
Thank You
Mansour


arbei
User
Posts: 9410

Post by arbei »

You may try to add Bootstrap class "img-fluid", see: https://getbootstrap.com/docs/4.0/conte ... ive-images.


mansour
User
Posts: 282

Post by mansour »

Hi,
I added the following code to: Global -> Pages with header/footer -> Client Script
// Make ColorBox responsive
jQuery.colorbox.settings.maxWidth = '95%';
jQuery.colorbox.settings.maxHeight = '95%';

// ColorBox resize function
var resizeTimer;
function resizeColorBox()
{
	if (resizeTimer) clearTimeout(resizeTimer);
	resizeTimer = setTimeout(function() {
			if (jQuery('#cboxOverlay').is(':visible')) {
					jQuery.colorbox.load(true);
			}
	}, 300);
}

// Resize ColorBox when resizing window or changing mobile device orientation
jQuery(window).resize(resizeColorBox);
window.addEventListener("orientationchange", resizeColorBox, false);

The problem solved!
Thanks


titanzik
User
Posts: 3

Post by titanzik »

This is brilliant! I used this in my project and it works great!

The it fixed my mobile orientation issue but now what happens is, although the image orientation on mobile is correct, the aspect ratio is still what it was before rotation. Do you know of a way to correct this?

Thanks!


Post Reply