Following the discussion from Responsive Images on the Fly (like TimberImage) · Issue #1984 · roots/sage · GitHub. Speaking of the usefulness and usage of an image generator like https://github.com/syamilmj/Aqua-Resizer or https://github.com/deliciousbrains/wp-image-processing-queue.
So on large websites you can end up with a lot of space used for nothing, plus the backoffice begins to slow down on every image upload.
This is happening automatically anyway. You are gonna get several images stuffed into the upload directory whether you use them or not.
I don’t think so, since only images requested by the front office when users visit it are generated. From my test, they’re not generated at upload. Only an image compression plugin could slow down the process here. Actually, I even remove all standard image sizes first:
/**
* https://paulund.co.uk/remove-default-wordpress-image-sizes
*/
function paulund_remove_default_image_sizes( $sizes) {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['medium-large']);
unset( $sizes['large']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'paulund_remove_default_image_sizes');
And then request new formats when I need it:
@php($pic = aq_resize(get_field('picture')['url'], 1200, null, false, false, true))
<img src="{{$pic[0]}}" alt="{{the_title()}}" width="{{$pic[1]}}" height="{{$pic[2]}}">
Querying image format right from the theme allows more modular usage and scales better.
How do you handle small screens vs. larger screens? 2X retina versions? I just can’t see something like Aqua Resizer handling this without a lot of logic dumped into your Blade file.
It’s pretty straightforward and modular, and yes the “logic” is in the template, because it’s where it’s needed IMO:
@php($thumb = aq_resize(get_field('cover')['url'], 600, null, false, false, true))
@php($retina = aq_resize(get_field('cover')['url'], 1200, null, false, false, true))
<img
src="{{$thumb[0]}}"
srcset="{{$thumb[0]}} 1x, {{$retina[0]}} 2x"
alt="{{the_title()}}"
width="{{$thumb[1]}}"
height="{{$thumb[2]}}">
These are simple examples, but I have some images that need different ratio according to the screen sizes, each one generated in @1x and @2x. It’s a lot, but sometimes it’s needed. But if I had to do it the Wordpress way, these N number of images would be multiplied for each format for each image of the site.
Any feedback or idea appreciated