mindkomm / timmy

Advanced image handling for Timber.
MIT License
171 stars 13 forks source link

get_timber_image_responsive_acf doesn't deliver image but error message #34

Closed bt-mo closed 4 years ago

bt-mo commented 4 years ago

Hi,

if I use the function get_timber_image_responsive_acf in my twig files like this: <img class="" {{ get_timber_image_responsive_acf('image_file', 'blog-post-full') }}>

I get following notice:

Notice: Trying to access array offset on value of type int in \mindkomm\timmy\functions-images.php on line 452
src=“ sizes="(min-width: 43rem) 860px, 100vw" srcset="//localhost:3000/app/uploads/2020/04/img-375×0-c-default.jpg 375w, //localhost:3000/app/uploads/2020/04/img-500×0-c-default.jpg 500w, //localhost:3000/app/uploads/2020/04/img-750×0-c-default.jpg 750w, //localhost:3000/app/uploads/2020/04/img-800×0-c-default.jpg 800w, //localhost:3000/app/uploads/2020/04/img-860×0-c-default.jpg 860w, //localhost:3000/app/uploads/2020/04/img-1000×0-c-default.jpg 1000w, //localhost:3000/app/uploads/2020/04/img-1125×0-c-default.jpg 1125w, //localhost:3000/app/uploads/2020/04/img-1500×0-c-default.jpg 1500w, //localhost:3000/app/uploads/2020/04/img-1800×0-c-default.jpg 1800w, //localhost:3000/app/uploads/2020/04/img-2100×0-c-default.jpg 2100w, //localhost:3000/app/uploads/2020/04/img-2400×0-c-default.jpg 2400w" 
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"“ alt=““ title=““>

The image does not show, the HTML looks like this: <img class="" <br="">

When using this instead: <img class="" {{ Image(fields.image_id)|get_timber_image_responsive('blog-post-full') }}> it works perfectly.

Is it just me or did anyone encounter this problem as well?

gchtr commented 4 years ago

Nah, it’s not only you, it‘s probably everybody 😊. The reason is that this was a function I added very early when developing Timmy, and I didn’t touch it for a long long time, because there wasn’t a use case I would use it on.

I added a fix in https://github.com/mindkomm/timmy/commit/ac9871a4dc01cce6590aa210d13e21f0ae6c5f06 together with tests, so that errors like these shoudln’t happen in the future for the get_timber_image_responsive_acf() function.

This should now be fixed with the 0.14.5 release.