V.2.4 update breaks image links

I just updated my site to v.2.4.

there is an error preventing the site to display. The original code in the template is

<a href="<?= $current->url() ?>"><img src="<?= $image->url() ?>" alt="<?= $current->title() ?>"
      srcset="<?= $image->resize(352)->url() ?> 352w,
        <?= $image->resize(680)->url() ?> 680w,
        <?= $image->resize(704)->url() ?> 704w,
        <?= $image->resize(1008)->url() ?> 1008w,
        <?= $image->resize(1336)->url() ?> 1336w,
        <?= $image->resize(1360)->url() ?> 1360w,
        <?= $image->resize(1664)->url() ?> 1664w,
        <?= $image->resize(1992)->url() ?> 1992w,
        <?= $image->resize(2016)->url() ?> 2016w,
        <?= $image->resize(2672)->url() ?> 2672w,
        <?= $image->resize(3328)->url() ?> 3328w,
        <?= $image->resize(3984)->url() ?> 3984w,
        <?= $image->resize(5344)->url() ?> 5344w"
      sizes="(max-width: 22rem) 352px,
        (max-width: 42.5rem) 680px,
        (max-width: 63rem) 1008px,
        (max-width: 83.5rem) 1336px,
        (max-width: 104rem) 1664px,
        (max-width: 123.5rem) 1992px,
        2672px" /></a>

in the browser the source code is highlighted in red and not showing on the page :

<img src="http://my-site.com/content/1-collections/4-autumn-winter-2016-2017/sessun-autumn-winter-16-17.jpg" alt="Autumn-Winter 2016-2017"
      srcset="http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-352x176-blur.jpg 352w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-680x340-blur.jpg 680w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-704x352-blur.jpg 704w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-1008x504-blur.jpg 1008w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-1336x668-blur.jpg 1336w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-1360x680-blur.jpg 1360w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-1664x832-blur.jpg 1664w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-1992x996-blur.jpg 1992w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-2016x1008-blur.jpg 2016w,
        http://my-site.com/thumbs/collections/autumn-winter-2016-2017/sessun-autumn-winter-16-17-2672x1336-blur.jpg 2672w,

there is no more code after this on the page…

Could you somehow send me access to your setup? bastian@getkirby.com

Is it ok if i make a .zip of the full website?

yes, of course! If it’s not 200 MB big :slight_smile:

Sorry little offtopic but isnt this a little excessive? 13 versions of one image? I mean there is 20px difference in the first step.

I asume this is test, because if its not its totaly not worth it. Just use something small for old mobiles, something for tablet, something for regular fullhd desktop and then the highest def for hidensity. Even that is probably overengineering.


Why is it “not worth it”?

Just my 2 cents on this topic, as I spent a lot of time thinking about these issues:

This is a very hard question in general. If you really want to overshoot on that topic, you could possibly create something like the hosted image-resizing service Cloudinary. They provide a free tool with a paid API, that applies a »smart« algorithm (I guess what they really mean is brute-forcing …) to select the right sizes for an image. Ehm … okay, one could use that and the results are quite okay, but does it really make sense to rely on a third-party for such tasks as they may change their API anytime soon or shutdown the service, which might not be too easy to replace.

Another option is to serve stronger-compressed images to so-called retina displays, as the smaller pixels on these screens make JPEG artifacts less noticable. But that also means, that you need twice the amount of thumbnails. If you really want to squeeze the last byte out of your site, but also want to serve high-density displays. But to keep things sane, I would agree with you that in most cases about 5-6 images should be enough to make a good compromise between the effort it takes to generate and store all these images and the overall download size. Take a look around at the web and do some comparison with most other sites and you can be glad, that with only 5-6 images, your site will perform much better than an estimated 90% of other websites.

1 Like

The size difference between for example a 1336px wide image and a 1360px wide image is not much.

If you don’t use something like (the amazing) Imagekit, Kirby will have to resize the image >10 times every time you upload a new image before loading the actual page. If there are many images, you might even have to increase your max_execution_time. It slows things down and it doesn’t even help that much.

1 Like

My hints:

  • Make sure the /thumbs folder exists and is writable for the webserver (permissions/owner on the file system, if it is not windows!).
  • Make sure the used thumbs driver exists and works on your webserver (XAMPP on windows has only the default kirby driver gd: https://getkirby.com/docs/cheatsheet/options/thumbs-driver).

Good luck!

Hey thanks HeinerEF. Bastian solve it by email. The GD library was timing out. Now I use imageMagick and everything is fine.

About the conversation to know if it is worth it or not to have that many variations. Yes this is a bit more work for me (to make the srcset) but as long as the thumbnails are pre-processed, and there is enough space on the server why not serve images to their exact size? I don’t see the problem.

The fact you can do that doesnt mean you should do it. Its exacltly like someone said in above comments. You could theoreticaly make image for every single resolution. But why it is just sily?

Just measure it:
There is realy not that big advantage if the image is same (is just scaled). You would target lowres screens like older mobiles and then there is jump to old tablets 1024px or something and then you would go for something like 1400 and then the high res. The point is that difference in size from 1400px and 1024px is almost nothing. Those resolutions are going to be mostly served by desktops anyway - so the size realy matters only on mobile phones. You realy need just like 5 steps probably less to achieve the same thing.

And frankly - you will probably waste much more kilobytes by setting up compresion of the images wrong than by not having exaclty right resolution.

If you would need the best and smallest images i would say you need some dedicated service like jpegmini or compressor.io those compress in smarter way then GD or imagemagic. But again this makes sense only for huge sites where the savings 50 kbs on image can save you money.