This is my first question, so please ignore the errors, if any.
I have a problem when I serve three alternative layouts to my visitors based on the device on which they are viewing.
Mobile, tablet, and desktop .
My site is in PHP and I use only 280 bytes of JavaScript to determine the width of my visitorβs browser. There is no other JavaScript or any libraries like jQuery, MooTools. I want my site to be very light, which leads to faster page loading speed.
I have a PHP variable with a name $layout, and a value for it is assigned by JavaScript dynamically based on the width of the browser. Three values ββassigned to them:mobile or tablet or desktop
Now I have links in my xhtml that look like this:
<img src="cdn/images/desktop/image1.jpg" width="500" height="200" alt="image1">
<img src="cdn/images/desktop/image2.jpg" width="500" height="200" alt="image2">
<img src="cdn/images/desktop/image3.jpg" width="500" height="200" alt="image3">
By default, images are downloaded from a folder cdn/images/desktop.
I am looking for if the value $layoutis equal tablet, then the images should be loaded from the folder cdn/images/tabletand similarly if valur $layoutis mobilethen the images should be loaded from cdn/images/mobile.
The name of the images remains unchanged. These are three different resolutions in three different folders.
Please offer a PHP solution, if possible, in PHP.
Otherwise, offer a simple JavaScript solution (libraries such as jQuery, MooTools from any such)
thank
UPDATE
Joomla CMS, PHP- , , , .