使用下面的代碼,我將圖像加載到Wordpress上的jQuery滑塊的縮略圖頁面。這工作正常,但問題是,它使用巨大的圖像和調整到小尺寸。這使我的網頁加載速度變慢。所以我在函數中創建了一個自定義圖像大小。這會創建一個名爲slide-181x86.jpg的新小圖像。我的問題是,如何修改最後一行jquery,在url結尾處添加-181x86而不是在jpg結尾處?我一直在收到slide.jpg-181x86,這顯然不對。jQuery Cycle pager附加較小的圖像大小
我一直在對此自殺,任何幫助將不勝感激。
<script type="text/javascript">
jQuery(function() {
jQuery('.homeslider').cycle({
speed: 'fast',
timeout: 7000,
fx: 'fade',
slideResize: false,
containerResize: false,
fit:1,
pager: '#slitemshome',
pagerAnchorBuilder: function(idx, slide) {
return '<li><a href="#"><img src="'
+ jQuery(slide).find('img').attr('src')
+ '" width="181" height="86" /></a></li>';
}
});
});
</script>
編輯:
我只是試圖功能
jQuery('#slitemshome img').attr('src', function(){this.src.replace('.jpg', '-181x86.jpg')})
後做這做那不顯得無所不用其極的URL。唉
更新到原始帖子 – brianr1