[英]Loop through all images and change size?
The script below works for posts that are already on the page. 以下脚本适用于页面上已经存在的帖子。 But, when I click on load more posts, the new posts that get added to the page don't change the source of the image so that they are blurry.
但是,当我单击“加载更多帖子”时,添加到页面上的新帖子不会更改图像的来源,因此它们很模糊。
Is there a way to loop through all images and change the src
of it, even the ones that are not shown? 有没有办法遍历所有图像并更改其
src
,即使未显示的图像也是如此?
function resizeThumb(size) {
var popularPost = document.getElementById('Blog1');
var image = popularPost.getElementsByTagName('img');
for (var i = 0; i < image.length; i++) {
image[i].src = image[i].src.replace(/\/s72\-c/g, "\/s" + size + "-c");
image[i].width = size;
image[i].height = size;
}
}
// Resize to 200 × 200
resizeThumb(200);
Yes. 是。 Basically locate the button that loads more, find it's name.
基本上找到加载更多的按钮,找到它的名称。
If your button looks like this: 如果您的按钮如下所示:
<a href="javascript:loadmore();"> Load more </a>
Put this before it so it looks like this: 将其放在其前面,因此如下所示:
<span onclick="resizeThumb(200); ">
<a href="javascript:loadmore();"> Load more </a>
</span>
It's the lousiest solution but the question is lousy too. 这是最糟糕的解决方案,但问题也很糟糕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.