Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
Is there a way to get image width and height at build-time in webpack?

I am using webpack to bundle an application, this app has a component that lazy loads images when they are scrolled into the viewport using intersection observer. As some of these images are portrait and others landscape I want a solution that enables me to prevent the 'popcorn effect' whilst the images are still loading. One way I thought about doing this was to compute the image dimentions at build-time and pass them into the component, something like:

<LazyLightbox
  src={imageSrc}
  thumbSrc={thumbSrc}
  thumbWidth={() => someWebpackFunctionThatComputesWidth(thumbSrc)}
  thumbHeight={() => someWebpackFunctionThatComputesHeight(thumbSrc)}
/>

... which when i run my build script produces something like...

<LazyLightbox
  src={imageSrc}
  thumbSrc={thumbSrc}
  thumbWidth={'200px'}
  thumbHeight={'120px'}
/>

That way the placeholder (before the thumb loads) would be the same dimentions of the thumb image that eventually loads.

Thanks in advance for any help or advice you can provide.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda