- This topic has 7 replies, 2 voices, and was last updated 5 years ago by
David.
-
AuthorPosts
-
November 10, 2018 at 10:02 pm #724230
leo
I’m using the Aspire theme, with the page hero element. Is it possible to use different background hero images on desktop and mobile? It is impossible to find an image size that works well on both.
November 11, 2018 at 4:20 am #724327Leo
StaffCustomer SupportHi there,
Give the page hero a class like
my-page-hero, then this CSS should work:@media (max-width: 768px) { .page-hero.my-page-hero { background-image: url(http://MOBILE-IMAGE-URL) } }Let me know if this helps 🙂
November 11, 2018 at 5:56 am #724376leo
This will not work, because there is a different hero image on every page.
November 11, 2018 at 8:10 am #724567David
StaffCustomer SupportHi there,
there is no simple way to switch a background image to mobile aside of the method Leo suggested.
Personally i upload an image at the maximum size i require it e.g 1920 x 1080.
I then use the image ratio for combined top and bottom padding: 1080 / 1920 = 56%. This should keep the image in full view.If you have content in the hero then you will need to adjust the % down to take into account. It takes a bit of trial and error but if you keep all images the same size and content to similar size will help.
November 11, 2018 at 8:39 am #724591leo
Thanks David, that is a method I was not really aware off. I’ll give it a go.
November 11, 2018 at 8:43 am #724595David
StaffCustomer SupportLet us know, but please note this won’t work if you are using the merged site header and full screen options.
May 7, 2021 at 1:56 pm #1769577Foundry
One option is to use the snippet that Leo provided:
@media (max-width: 768px) { .page-hero.my-page-hero { background-image: url(http://MOBILE-IMAGE-URL) } }Put it in your functions.php file (or an include, as I do). Wrap it with a custom function to grab a custom field for the mobile URL, set for each page you need it on. You can set it to have a fallback image, too. I’m not going to explain how to do that, there are plenty of resources a couple keys and clicks away.
This is a theory at this point.
I’m going to try it out and will report back if it suits our needs.
May 8, 2021 at 4:27 am #1770069David
StaffCustomer SupportHi there,
thanks for sharing your options – i am not sure if the OP is still is working on this as the topic is over 2 years old 🙂
Heres an example method where we swap the hero background image on mobile for a smaller attachment file:
You can change the variable to grab a custom field if required.
-
AuthorPosts
- You must be logged in to reply to this topic.