调整图像大小,然后将砌体应用于它们

时间:2013-11-20 17:13:08

标签: javascript jquery html

我正在尝试重新调整一些默认widthheight设置为400px300px的图片。为此,我正在使用此代码:

var ids = new Array();
var tiw = ['200','300'];
var tih = ['150','200'];
jQuery('.ngg-gallery-thumbnail-box').each(function(index) {
    ids[index] = jQuery(this).attr('id');
});

function shuffle(o){ //v1.0
    for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
    return o;
};
ids = shuffle(ids);

j = 0;
jQuery.each(ids,function(i, val){
    j = (j>2)?0:j;
    jQuery('#'+val).find('img').width(tiw[j]).height(tih[j]);
    j++;
});

var $container = $('.ngg-galleryoverview');

$container.masonry({
    itemSelector: '.ngg-gallery-thumbnail-box'
});

出于某种原因,某些图像保持默认值,我不希望这样,因为我无法使用masonry jquery plugin处理。您可以采取实时示例here可以给我任何建议或更好的解决方案吗?我需要实现的是将默认值调整为另一个值,以使砌体比现在更好地工作

0 个答案:

没有答案