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

[Bug] If an image is scalable or not is not determined correctly #453

Open
4 tasks done
aona42 opened this issue Nov 4, 2023 · 1 comment
Open
4 tasks done

[Bug] If an image is scalable or not is not determined correctly #453

aona42 opened this issue Nov 4, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@aona42
Copy link

aona42 commented Nov 4, 2023

I confirm:

Hugo version

v0.120.3-a4892a07b41b7b3f1f143140ee4ec0a9a5cf3970+extended

Where is this bug showing up?

In the browser: Hugo builds the site, but something doesn't look right.

Operating system

Debian Bookworm

Browser (if applicable)

Firefox 115.4.0esr

Current behavior

When I add an image larger then the post-width to a post it should automatically be scalable means one can click on it and it scales to full screen size. This works fine if the image is initially visible when the page is opened because then the image is loaded directly. However, other images "much further down in the post" are not clickable for me. It seems that the JavaScript function in index.js which determines if an image is scalable or not only does this initially when the page is opened. Since the lazily loaded images are not yet available then, their naturalWidth is 0 and all these images are not scalable then.

Expected behavior

Lazily loaded large images should also be scalable.

Steps to reproduce

  • create a post
  • add a large image which is lazily loaded "further down in the post"
  • open the post in the browser and scroll down to the image, it is not clickable

Note: Make sure that the image is not cached. Best is to disable the browser cache in the developer tools.

Relevant log output

No response

Related code

assets/js/index.js

Preferred solution

No response

Other information

No response

@aona42 aona42 added the bug Something isn't working label Nov 4, 2023
@aona42
Copy link
Author

aona42 commented Nov 4, 2023

"Workaround" can be to add the CSS class image-scalable manually to these images to make them always scalable, but of course this is not optimal.

@onweru onweru self-assigned this Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants