question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retina images don't preserve aspect ratios

See original GitHub issue

I have one portrait image, which looks stretched. What I did was adding this to config:

ratio: 1.5,
replaceSrc: function(item) {
   return item.src.replace(/\/\d+\//, function () {
      return '/1920/';
    });
}

my images come in different widths though, so I was not using the @2x modifier. When I open the image, it fills the screen height, but the width seems to be wrong.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
rainerroesingcommented, Dec 12, 2015

I solved it by removing the bold lines.

if(ratio > 1) {
                    _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) {
                        item.img.css({
                         'max-height': item.img[0].naturalHeight / ratio,
                         'width': 'auto'
                        });
                    });
                    _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) {
                        item.src = st.replaceSrc(item, ratio);
                    });
                }
0reactions
Hip-Priestcommented, Mar 18, 2015

I’m seeing this too. Had me very confused for a while! Any fixes for it yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS force image resize and keep aspect ratio - Stack Overflow
By specifying both you are changing the aspect ratio of the image. Just setting one will resize but preserve the aspect ratio.
Read more >
New aspect-ratio CSS property supported in Chromium, Safari ...
Maintaining aspect ratio within images and elements is now easier to achieve with the new aspect-ratio CSS property.
Read more >
3 Ways to Keep Image Aspect Ratio In HTML CSS - Code Boxx
To maintain the aspect ratio of images in CSS, the easiest way is to manually set the dimension of the width, then the...
Read more >
Preserve an Image's Aspect Ratio When Resized | kirupa.com
Learn this one simple CSS trick to ensure your images resize automatically while ensuring the aspect ratio is maintained.
Read more >
aspect-ratio - CSS-Tricks
Browsers do some fancy aspect ratio calculations on replaced content like images. So, if an image has, say, a width of 500px, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found