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

How to apply retina.js only to .png files? #222

Open
bisonbrah opened this issue Dec 2, 2015 · 1 comment
Open

How to apply retina.js only to .png files? #222

bisonbrah opened this issue Dec 2, 2015 · 1 comment
Labels

Comments

@bisonbrah
Copy link

I'm only using retina.js for png image types. How would I only trigger retina.js to check for @2x for only png? I have a ton of jpeg and the console error codes are driving me nuts >.<.

Thanks in advance for the assistance!

@christoshrousis
Copy link

Add an attribute to your html markup data-no-retina or if there's too many

Replace the following lines:
https://github.com/imulus/retinajs/blob/master/src/retina.js#L38-L46

with SOMETHING like this:

for (i = 0; i < images.length; i += 1) {
  image = images[i];
  if (image.src) {
    var imageSource = image.src,
    imageExt    = imageSource.substr(imageSource.lastIndexOf('.') + 1);

    if (!!!image.getAttributeNode('data-no-retina') && imageExt == 'png ') { 
        retinaImages.push(new RetinaImage(image));
    }
  }
}

Stolen from here:
https://github.com/jeremymouton/retinajs/blob/master/src/retina.js#L52-L63

@strues strues added the legacy label Jun 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants