html - Feeling completely lost with responsive images using srcset and sizes -


i've been trying optimize images on photography site using srcset , sizes, inspector in browser telling me it's loading largest image size. confirm this, added new image numbers can see sure size image being loaded.

but no matter how mess media queries, can't work properly. assume issue related writing media queries incorrectly, i'm kind of @ wits end. i've tested in every way possibly think of. read on post here, browser caching larger image. tried in multiple browsers, , in incognito mode.

as shown below, images called "test" load middle sized image, never smallest one.

below section of code. you'll notice i'm using responsively loaded (sized) images in href tag, it's part of lightbox.

you can see page in question @ https://www.jeffreygelt.com/alt/.

here's code:

    <a href="/alt/img/portfolio/test-1000x667.jpg"          data-sizes="(min-width: 880px) 1000px, 400px"         data-srcset="             /alt/img/portfolio/test-400x267.jpg 400w,             /alt/img/portfolio/test-800x533.jpg 800w,             /alt/img/portfolio/test-1000x667.jpg 1000w">         <picture>             <img class="img-responsive"                 sizes="(min-width: 880px) 400px,                        (min-width: 660px) , (max-width: 879px) 800px,                        (min-width: 400px) , (max-width: 659px) 400px, 1000px"                 srcset="                     /alt/img/portfolio/test-400x267.jpg 400w,                     /alt/img/portfolio/test-800x533.jpg 800w,                     /alt/img/portfolio/test-1000x667.jpg 1000w"                 src="/alt/img/portfolio/test-1000x667.jpg"                 alt="asbury park">         </picture>     </a>      <a href="/alt/img/portfolio/andy-533x800.jpg"          data-sizes="(min-width: 880px) 533px, 395px"         data-srcset="             /alt/img/portfolio/andy-395x593.jpg 395w,             /alt/img/portfolio/andy-419x629.jpg 419w,              /alt/img/portfolio/andy-533x800.jpg 533w">         <picture>             <img class="img-responsive"                  sizes="(max-width: 880px) 533px, 395px"                 srcset="                     /alt/img/portfolio/andy-395x593.jpg 395w,                     /alt/img/portfolio/andy-419x629.jpg 419w,                     /alt/img/portfolio/andy-533x800.jpg 533w"                 src="/alt/img/portfolio/andy-533x800.jpg"                 alt="andy's portrait" />         </picture>     </a>     

for column view simple: sizes="(max-width: 400px) 99vh, (max-width: 880px) 49vw, 285px". hope start understand (with example). lightbox view little bit more complicated because both width , height dependent , sizes supports width descriptors. in case of viewport width , viewport height constrained images can calculate image width using vh unit in combination width aspect ratio of image.

you can see more informations here: can use <picture> both height , width-constrained images?

also note: browser multiply calculated sizes length devicepixelratio generate needed width of image. , chrome loads largest image, if in browser cache.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -