Serving different number of images depending on dimension


Is there any trivial (or non-trivial) way to serve different quantity of images (->limit()) depending on the dimensions of the window? I’m trying to create a grid with different number of images inside depending on the dimensions of the browser window.

In CSS we could show X number of images and hide the rest with media queries; but I was wondering if that’s something we can do somehow straight with PHP.

Thanks, as always.

As a server-side language, PHP doesn’t know anything of the browser’s window dimensions. You would have to send this information from the client to the server via AJAX, then retrieve the relevant content from the server.

1 Like