Archived topic
Need Advice - image/banner slider
3 replies · Started by roadlink on February 13, 2021
Hello,
I have to show static banners in slider with links.
I tried many sliders but have some issues.
Banner and links work great in desktop, but when it is mobile slider use same size image and it cause low score on page speed insights. "Use correct size of images"
I can make 2 banners, 1 for desktop and 1 for mobile.
But I want to make sure only 1 of them really loaded each time. (not css hide)
or image can be resized by using same ratio for mobile.
I really did search a lot and tried many slider plugins.
Do you have any advice for this?
Hi there,
Unfortunately I don't believe there is a solution for this.
You could try looking into this function but I'm not sure if it would work for sliders:
https://developer.wordpress.org/reference/functions/wp_is_mobile/
For this type of general WordPress question, it might be worth asking on a general WordPress forum like this:
https://wordpress.stackexchange.com/
I tried this one and seems OK for now.
This one to hook
<div class="sliderdiv">
<?php
if ( wp_is_mobile() ) {
echo do_shortcode('[metaslider id="390637"]');
} else {
echo do_shortcode('[metaslider id="2703"]');
}
?>
</div>
This one to additional css
/* Slider div settings */
.sliderdiv {
padding: 5px 0px 5px 0px;
}
Glad to hear.