Changing layout of defaul gallery output to masonry

try it like this:

$.each($('.gallery img'), function () {
  var rndmnum = Math.floor((Math.random()*11)+1);
  rndmnum = rndmnum *20 + 260;

  $(this).css({
     'max-width' : rndmnum
  });
});

note: untested

sources:
https://stackoverflow.com/questions/8904707/javascript-random-number-between-15-and-225-increments-of-30
https://stackoverflow.com/questions/8733838/random-max-width-for-each-image-on-a-page

edit: corrected calculation