如何替换 Array.prototype.map.call 包括 <img> 标签

How to replace Array.prototype.map.call including <img> tags

我在我的博客中使用了以下代码段。

Array.prototype.map.call(document.getElementsByTagName("img"), img => img.src);

我得到图像 src 的输出:-

它可以在我的 post 中获取我的所有图像。但面临问题 s1600

我需要通过 array.prototype.map.call 或任何其他字符串

s1600 更改为 s320

您可以使用replace()方法。

Array.prototype.map.call(document.getElementsByTagName("img"), 
    img => img.src.replace('/s1600/', '/s320/'));