Eddyfever
Eddyfever

Reputation: 81

Remove character from img src

I want to edit my img src and so far i found this:

$('.foo').attr('src', function(index, attr) {
    return attr.replace(/\.[^.]*$/, '-thumb$&');
});

But this adds -thumb so i thought remove would do the trick but it doesn't. What is the best way to do this?

Upvotes: 0

Views: 738

Answers (1)

Jonas Høgh
Jonas Høgh

Reputation: 10874

$('.foo').attr('src', function(index, attr) {
    return attr.replace("-thumb", "");
});

Edit:

Will this work?

$('.foo').attr('src', function(index, attr) {
    return attr.replace("%7Bthumdir_3%7D", "images/thumbs/");
});

or does the pattern of the string which is "%7Bthumdir_3%7D" in your example vary?

Upvotes: 1

Related Questions