Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
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.

over 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Asistente virtual