getCustomImageURL & srcset

Roland Member, Translator

Hello !
I'm trying to update my theme with responsive image srcset attribut
by using getCustomImageURL(); function.

Theoretically this code should be okay :

<img alt="<?php echo getBareImageTitle() ?>" src="<?php echo html_encode(getCustomImageURL(NULL,916,NULL,NULL,NULL,NULL,NULL,false,NULL)); ?>" srcset="<?php echo html_encode(getCustomImageURL(NULL,640,NULL,NULL,NULL,NULL,NULL,false,NULL)); ?> 640w,<?php echo html_encode(getCustomImageURL(NULL,916,NULL,NULL,NULL,NULL,NULL,false,NULL)); ?> 916w,<?php echo html_encode(getCustomImageURL(NULL,1030,NULL,NULL,NULL,NULL,NULL,false,NULL)); ?> 1030w" sizes="(min-width: 1366px) 916px,(min-width: 1536px) 1030px, 100vw">

But's it's not working :p

The generated html is :
<img alt="bpt6k6579564s_f3" src="/zenphoto/cache/Abstract/bpt6k6579564s_f3_w916.jpg?cached=1614254337" srcset="/zenphoto/zp-core/i.php?a=Abstract&amp;i=bpt6k6579564s_f3.jpg&amp;w=640&amp;cw=0&amp;ch=0&amp;q=88&amp;wmk=!&amp;check=4c293b2ae1528952a1fd27a9f9b280604408d2c8 640w,/zenphoto/cache/Abstract/bpt6k6579564s_f3_w916.jpg?cached=1614254337 916w,/zenphoto/zp-core/i.php?a=Abstract&amp;i=bpt6k6579564s_f3.jpg&amp;w=1030&amp;cw=0&amp;ch=0&amp;q=88&amp;wmk=!&amp;check=1539ea8382eeae30f4e9b840ec6b43616fb6250a 1030w" sizes="(min-width: 1366px) 916px,(min-width: 1536px) 1030px, 100vw">

So I'm guessing, Zenphoto cache only for the src attribute.

Is this something I can trick anywhere ? Maybe theme functions ?

Thanks for your help !

Tags:

Comments

  • acrylian Administrator, Developer
    edited February 2021

    All is fine actually. The urls you see are the image processor urls. These are only executed on request, if needed. Since the browser here picks the image size automatically it thinks is best, these are not picked and therefore not executed. The browser picks this based on teh browser window width and image widht needed for display and on page reload, not on the fly.

    You can register the sizes with the cacheManager to pre-cache them manually. But this is normally not needed.

  • Roland Member, Translator

    Thanks Acrylian !!

    I figured out why I had error with some pictures.
    -> Because I didn't use the seo_cleanup plugin to clean files and folder names :smile:

    Now it's working : https://archives.rolandtisserand.fr/cycling-amsterdam-paris/20150613-_mg_9483.jpg

    I'm just a bit disappointed because the browser doesn't reload the right img on the fly. But's it's not a Zenphoto issue !

  • acrylian Administrator, Developer

    Good you got it working. I guess some French special chars/accents caused trouble?

    I'm just a bit disappointed because the browser doesn't reload the right img on the fly.

    Yeah, but after the page has been loaded it would need extra JS for that. Thus the reload. But who know what they might do in the future.

  • Roland Member, Translator

    You guess right :)

Sign In or Register to comment.