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

Responsive Image placeholders #80

Open
mollybrowntown opened this issue Aug 13, 2020 · 2 comments
Open

Responsive Image placeholders #80

mollybrowntown opened this issue Aug 13, 2020 · 2 comments
Labels
question Further information is requested

Comments

@mollybrowntown
Copy link

Hi there,

I'd like to suggest support for responsive images (ie, on windows expanding). The issue I face is that the placeholder Img only shows up when a width and height are passed into the component props. If I only want the width of 100% to be set on my images to respond to differing window sizes, the placeholder doesn't show up. Also, as an alternative, if I set the CSS for the placeholder blur image to contain a height, the height of the span remains after the load. So unwanted content changes occur.

@samatcd
Copy link

samatcd commented Nov 4, 2021

Yes, agreed! In most cases this would be achieved by removing the explicit width / height on the span.lazy-load-image-background element and having this element expand to full container width & height. Setting the passed image width / height attributes on the img tag as it does now, will allow the browser to scale images properly.

This could potentially be accomplished by setting a responsive prop or something similar on the LazyLoadImage component.

@jotacodestudio
Copy link
Collaborator

Thanks for bringing up this issue. I'm wondering if this solution could fit your needs:

<LoadImage
  alt={imageAlt}
  placeholder={
    <div
      style={{
        aspectRatio: "1/1",
        display: "block",
        width: "100%",
      }}
    ></div>
  }
  src={imageSrc}
  wrapperProps={{
    style: {
      display: "block",
      width: "100%"
    }
  }}
/>

react-lazy-load-image-component sets the display property of the wrapper and placeholder to inline-block. This is to mimic how an image would be laid out on the page. However, you can set them to 100% width using the wrapperProps and placeholder props.

@jotacodestudio jotacodestudio added the question Further information is requested label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants