Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何重写URL的某些部分?_Php_Jquery_Html - Fatal编程技术网

Php 如何重写URL的某些部分?

Php 如何重写URL的某些部分?,php,jquery,html,Php,Jquery,Html,我在我的网站上有一些像下面这样的图片代码,从第三方网站到我的网站 <div class="thumb"><img src="//www.abc.com/website/thumbs/461/beautifulimage/test1a.jpg" rel="//www.abc.com/website/thumbs/461/beautifulimage/test1a.jpg"></div> 到 那么,我如何在页面加载时替换URL,以便加载如下代码 <div

我在我的网站上有一些像下面这样的图片代码,从第三方网站到我的网站

<div class="thumb"><img src="//www.abc.com/website/thumbs/461/beautifulimage/test1a.jpg" rel="//www.abc.com/website/thumbs/461/beautifulimage/test1a.jpg"></div>

那么,我如何在页面加载时替换URL,以便加载如下代码

<div class="thumb"><img src="//www.abc.com/website/thumbs/800/beautifulimage/test1a.jpg" rel="//www.abc.com/website/thumbs/800/beautifulimage/test1a.jpg"></div>


有什么方法可以这样调用URL吗?

我想这是将图像缩略图URL中的
461
更改为
800
的问题。这可以通过jQuery轻松解决。只需迭代所有缩略图,并将
/461/
替换为
/800/

这必须在文档准备好之后完成,这就是您可以做到的

$(document).ready(function(e){
    $('.thumb img').each(function(index){
       var urlpath=$(this).attr('src');
       urlpath=urlpath.replace("/461/", "/800/");
       $(this).attr('src',urlpath);
    });
});
演示:


我们使用jQuery函数对所有缩略图进行迭代,并使用jQuery函数设置和获取图像元素的
src

我使用的wordpress中的jQuery(document).ready(function(e){$('.thumb img')。each(function(index){var urlpath=$(this).attr('src')有何实现方法;urlpath=urlpath.replace(“/thumbs/461/”,“/images/”);$(this.attr('src',urlpath);});});'
<div class="thumb"><img src="//www.abc.com/website/thumbs/800/beautifulimage/test1a.jpg" rel="//www.abc.com/website/thumbs/800/beautifulimage/test1a.jpg"></div>
$(document).ready(function(e){
    $('.thumb img').each(function(index){
       var urlpath=$(this).attr('src');
       urlpath=urlpath.replace("/461/", "/800/");
       $(this).attr('src',urlpath);
    });
});