Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Url is encoded twice if already encoded #25

Open
petertflem opened this issue Apr 2, 2014 · 2 comments
Open

Url is encoded twice if already encoded #25

petertflem opened this issue Apr 2, 2014 · 2 comments

Comments

@petertflem
Copy link

It seems whenever the plugin gets an url that is already encoded, it encodes it again, thus destroying the url.

Perhaps you can test if it is encoded before encoding it, e.g. with a regex, something like /%[0-9A-Z]{2}/g. (that regex needs testing).

Maybe you can do like this:

if (!new RegExp(/%[0-9A-Z]{2}/g).test($img.attr('src'))) {
    // Change
    $imgBoxCont.css({ 'background-image': 'url("' + encodeURI($img.attr('src')) + '")' });
} else {
    // Change
    $imgBoxCont.css({ 'background-image': 'url("' + $img.attr('src') + '")' });
}
@funwhilelost
Copy link

Seeing the same thing here. I actually don't think we should need to encode the background-image URL at all.

@funwhilelost
Copy link

@petertflem I'm working around it by running this snippet just before running imgLiquid:

if (new RegExp(/%[0-9A-Z]{2}/g).test($img.attr('src'))) {
  $img.attr("src", decodeURIComponent($img.attr("src")));
}
$img.parent().imgLiquid({ ... });

YMMV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants