Shopify themes, liquid, logos, and UX
Hey everyone,
One last question for today: I have two images, and I want to display them based on the device being used. For example, I want image 1 to be shown on a desktop PC and image 2 on a mobile device. How can I achieve this?
Thanks!
Solved! Go to the solution
This is an accepted solution.
So there are many ways to do it but the simple way only using the css is below:
First create another image tag just below the current image and give it the mobile version url
<img src="{{'desktop-image.jpg' | assets_url}}" alt="Desktop Image" class="responsive-image desktop-image">
<!-- Mobile Image -->
<img src="{{'mobile-image.jpg' | assets_url}}" alt="Mobile Image" class="responsive-image mobile-image">
Then add css as below
/* Image for mobile devices */
@media only screen and (max-width: 768px) {
.desktop-image {
display: none;
}
.mobile-image {
display: block;
}
}
/* Hide mobile image on desktop */
@media only screen and (min-width: 769px) {
.mobile-image {
display: none;
}
}
Please adjust the code and class name based on your need.
Let me know if you need any further help.
This is an accepted solution.
This design requires a developer, or if you're comfortable with code, you can check this out.
Please don't forget to Like and Mark Solution to the post that helped you. Thanks!
This is an accepted solution.
Hi @Wanigajameson , kindly checkout the below videos
And
If my reply is helpful, kindly click like and mark it as an accepted solution.
Thanks!
This is an accepted solution.
So there are many ways to do it but the simple way only using the css is below:
First create another image tag just below the current image and give it the mobile version url
<img src="{{'desktop-image.jpg' | assets_url}}" alt="Desktop Image" class="responsive-image desktop-image">
<!-- Mobile Image -->
<img src="{{'mobile-image.jpg' | assets_url}}" alt="Mobile Image" class="responsive-image mobile-image">
Then add css as below
/* Image for mobile devices */
@media only screen and (max-width: 768px) {
.desktop-image {
display: none;
}
.mobile-image {
display: block;
}
}
/* Hide mobile image on desktop */
@media only screen and (min-width: 769px) {
.mobile-image {
display: none;
}
}
Please adjust the code and class name based on your need.
Let me know if you need any further help.
Hi @Wanigajameson ,
You have to modify the section to provide option to upload two images and media query to show appropriate image.
Request you to refer the below video how you can add these settings for section.
Hope this will help..., don't forget to like and mark as solution.
hello @Wanigajameson
I have made the code for you, you check the video, there is different image for desktop and different for mobile, if you want this then tell me and what is your theme
check the video:https://www.awesomescreenshot.com/video/31159662?key=7a4c6182d0e9a7ddb5047fdd0ecfb6d7
thanks
This is an accepted solution.
This design requires a developer, or if you're comfortable with code, you can check this out.
Please don't forget to Like and Mark Solution to the post that helped you. Thanks!
This is an accepted solution.
Hi @Wanigajameson , kindly checkout the below videos
And
If my reply is helpful, kindly click like and mark it as an accepted solution.
Thanks!
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024