Question

I wanted to update the img src rendered in wordpress media library

<a href="https://sample/group/wp-admin/post.php?post=159&amp;action=edit" title="Edit &#8220;NTPIII_Banner_41620134.jpg&#8221;">

<img src="http://sample/group/files/2014/01/NTPIII_Banner_41620134.jpg" class="attachment-80x60" alt="NTPIII_Banner_41620134.jpg" />                </a>

I wanted to replace HTTP to HTTPS as image is not showing when the src is HTTP

Was it helpful?

Solution

Try this:

$('img').each(function(){
    var newSrc = $(this).attr('src').replace('http', 'https');
    $(this).attr('src',newSrc);
});

Fiddle:

http://jsfiddle.net/TWQ3m/

OTHER TIPS

First have you tried this: HTTPS Plugin

Second you should use replace()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top