How to rewrite some part of the URL?
-
[Moderator Note: moved to Hacks Forum. The best forum for custom code questions]
I have some image thumb code like below on my website coming from third party website to my website
<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>
I want to replace URL from
//www.abc.com/website/thumbs/461
to
//www.abc.com/website/images
So, I can replace URL on page load so it’ll load code something like below<div class="thumb"><img src="//www.abc.com/website/images/beautifulimage/test1a.jpg" rel="//www.abc.com/website/images/beautifulimage/test1a.jpg"></div>
I find below script to make it work but it’s not working on wordpress
jQuery(document).ready(function($){ $('.thumb img').each(function(index){ var urlpath=$(this).attr('src'); urlpath=urlpath.replace("/thumbs/461/", "/images/"); $(this).attr('src',urlpath); }); });
Do you know guys how I can run this code after complete gadget load and then it’ll change all the URL??
- The topic ‘How to rewrite some part of the URL?’ is closed to new replies.