渠道顾问/Ebay图像质量问题 [英] Channel Advisor / Ebay Image quality Issue

查看:46
本文介绍了渠道顾问/Ebay图像质量问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的HTML上有图片src,如下所示:

If I have a image src on my HTML as follow:

http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/FrMAAOSweW5U3QvN/$_12.JPG?set_id=880000500F

我想将所有$ _12.JPG更改为$ _57.JPG,以获得更好的图像质量,如下所示:

and I want to change all $_12.JPG to $_57.JPG in order to get the better image quality like below:

http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/FrMAAOSweW5U3QvN/$_57.JPG?set_id=880000500F

我该如何使用Javascript来将HTML上的所有$ _12.JPG替换为$ _57.JPG?

How do I do this with Javascript so that it replaces all $_12.JPG on my HTML with $_57.JPG?

提前谢谢!!

推荐答案

您可以使用 .replace()更改URL,例如:

You can change the URL using .replace() for example:

document.getElementById('TheImage').src.replace('$_12.JPG','$_57.JPG');

这是一个小型演示,因此您可以在实际操作中看到它.

Here is a small demo so you can see this in action.

演示源代码

function URLswap(){
    //--Set image variable
    var curlink=document.getElementById('ebay');
    //--Replace unwanted sting with new string.
    var Newlink=curlink.src.replace('$_12.JPG','$_57.JPG');
    //---Set new src
    curlink.src=Newlink;
    //-- Display new src (text) in div
    document.getElementById('currentlink').innerHTML='New Src= '+Newlink;
}

<button onclick="URLswap()">Change</button><br>
<div id="currentlink">Current Src= http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/FrMAAOSweW5U3QvN/$_12.JPG?set_id=880000500F</div>
<img id="ebay" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/FrMAAOSweW5U3QvN/$_12.JPG?set_id=880000500F"/>

对于多张图像,您可以为这些图像提供 class 并使用for循环将其应用于具有该类的所有图像,但是由于您的问题或提及中没有任何源代码 id / class 的内容我只是保持答案和问题一样基本.

For multiple image you can give those images a class and use a for loop to apply this to all images with that class but since you don't have any source code in your question or any mention of id / class I'm just keeping the answer as basic as the question.

我希望这会有所帮助.祝您编码愉快!

I hope this helps. Happy coding!

这篇关于渠道顾问/Ebay图像质量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆