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

Images only partially loaded / cutoff / cropped #399

Open
CarlAmbroselli opened this issue Jul 3, 2023 · 0 comments
Open

Images only partially loaded / cutoff / cropped #399

CarlAmbroselli opened this issue Jul 3, 2023 · 0 comments

Comments

@CarlAmbroselli
Copy link

CarlAmbroselli commented Jul 3, 2023

For large image files (i.e. mine are >3000px per dimension), the fullscreen view can sometimes only load a part of the image and then cut it off on mobile Safari. Waiting does not solve this, back and forth also doesn't solve it, only the workarounds listed below. This does not happen for all images, but it happens esp. frequent for large images.

Screenshot (I cut off the bottom of the thumbnails since these are private photos, only the main image is cropped):

  • When I open devtools and change the height of the image to 100% and then change it back, the correct image size is shown
  • When I zoom in (i.e. by double-tapping) and then zoom out again, the issue is gone
  • When setting data-ngimagewidth / data-ngimageheight, this does not resolve the issue (the css height/width are set correctly, but the browser still renders it incorrectly)
  • When making the images interlaced, the issue is gone as well

Bonus, converting all your .jpg images in a folder to an interlaced version (that's what I've used):
for i in $(ls *.jpg); do docker run --entrypoint=convert --rm -v $(pwd):/img dpokidov/imagemagick /img/$i -interlace Plane /img/interlaced/$i; done

I've attempted something like the following, but it creates an ugly flicker (when switching to 100% height for 50ms) and only works in 90% of the cases:

  <script>
    let fixed = []
    window.setInterval(() => {
      pic = document.querySelector('.nGY2ViewerMediaPan.imgCurrent > .nGY2ViewerMedia')
      if (pic && fixed.indexOf(pic.src) === -1) {
        fixed.push(pic.src)
        $(pic).on('load', function() { 
              let current = document.querySelector('.nGY2ViewerMediaPan.imgCurrent > .nGY2ViewerMedia')
              fixed.push(current.src)
              current.style.height = "100%"
              let handle = current
              window.setTimeout(() => {
                handle.style.height = (handle.naturalHeight / handle.naturalWidth) * handle.width + "px"
              }, 50)
            })
          }
    }, 200)
  </script> 
@CarlAmbroselli CarlAmbroselli changed the title Images only partially loaded Images only partially loaded / cutoff / cropped Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant