如何替换html中所有出现的图像url
我有一个博主博客。我在我的每一篇博客文章(我的签名)中都放了一张图片。早些时候它托管在图像托管网站上,但现在我希望它把它放在我自己的网站上,因为旧托管网站可能随时删除它。如何用新的 url 替换所有出现的图像先前的 url,而无需在每个帖子中手动更改它?
手动完成几乎是不可能的,因为我已经发布了一百多个帖子。
就像我可以在模板中插入任何代码一样,每当打开页面时,该代码都会用新的网址替换以前的网址?
i have a blogger blog. there is one image which i put in each of my blog's post( of my signature). earlier it was hosted on an image hosting site but now i want it to put it on my own site since the old hosting site may delete it any time. how can i replace all occurrences of the image previous url with the new url without changing it manually in each post?
it is almost impossible to do it manually because i already have made more than a hundred posts.
like is there any code which i can insert in the template which will replace the previous url with the new one whenever a page is opened?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jQuery: -
如果您不确定如何使用 jQuery,请在此处发表评论,我将为您提供帮助。 Js Fiddle在这里: http://jsfiddle.net/jTnpk/
With jQuery: -
If you're not sure how to use jQuery comment here and i'll give you a hand. Js Fiddle here: http://jsfiddle.net/jTnpk/
您是否能够复制博客的所有 HTML 内容,因为如果您能够,那么您可以简单地将它们粘贴到任何好的文本编辑软件中,例如 记事本++
从那里,您可以在搜索下转到“替换...”,在一个中输入旧链接,在另一个中输入新链接后,点击“全部替换”,然后您可以复制所有代码并将其粘贴回来,如果您有该选项,如果没有,您可以向页面添加一个脚本,其内容如下所示:
Are you able to copy all of your blog's HTML contents, because if you were able to then you could simply paste them into any good text editing software like Notepad++
from there you could go to "Replace..." under search and after typing in the old link in one and the new link in the other hit "Replace All" and from there you could just copy all the code and paste it back, if you have that option, if not you could add a script to the page which goes a little something like this: