Search code examples
javascriptjquerycolorbox

ColorBox maximum size


How can I limit the maximum size of ColorBox?

jQuery(document).bind('cbox_open', function(){
    jQuery.colorbox.maxWidth = '90%';
    jQuery.colorbox.maxHeight = '90%';
});

This code is not working.(((


Solution

  • Use Scalephotos

    If true, and if maxWidth, maxHeight, innerWidth, innerHeight, width, or height have been defined, Colorbox will scale photos to fit within the those values.

    $("a.gallery").colorbox({rel: 'gal', scalephotos:true title: function(){
      var url = $(this).attr('href');
      return '<a href="' + url + '" target="_blank">Open In New Window</a>';
    }});