Jump to content

Code to prevent mobile fallback image briefly showing before background video loads.

Go to solution Solved by ArminB,

Recommended Posts

site link:ย https://onetreehill.squarespace.com/contact

password: batcar1962

Hi,

Issue 1: My client has requested a background video on the contact page. I have set an image for the mobile fallback, but when you go to the contact section, the fall-back image is showing briefly before the video loads.ย I have no coding experience. I have found some codes posted in other forum posts, but could not get them to work when pasting them in the css box.

Issue 2: The video also has sound which the client would like to work if possible. I understand that background auto-load videos don't play sound and that there are issues around this with browsers etc, so no problem if this can't be fixed, but if code can be provided for the sound, that would be a bonus.

Thank you

Link to comment
  • Solution

Hey!

Issue 1: Just make a screenshot of the first frame of the video and use this as the fallback. This should be a smoother experience.

Issue 2: Most browsers would block background video autoplay anyway so rather not ๐Ÿ™‚

https://developer.chrome.com/blog/autoplay/

Edited by ArminB

About Armin:
Squarespace Expert Profile: https://www.squarespace.com/designer/profile/3649084
Website: www.braunsberger-media.com

Link to comment
  • 2 months later...
On 3/14/2023 at 12:04 PM, mukr said:

I made a gif for the fallback image. I don't want to use a screenshot. Any other ideas or coding on solving issue 1?

If you share site url, we can check & give code easier

Email meย if you have need any help (free, of course.). Answer within 24 hours.ย 
Or send to forum message

Contact Customer Careย - Learn CSSย - Buy me a coffeeย (thank you!)

Link to comment
  • 3 weeks later...
On 4/15/2023 at 3:15 AM, mukr said:

Thank you!

I just tried this and it's still showing the fallback image for a second. Any other tips?

Use this code

@media screen and (max-width:640px) {
section#introduction-impact img {
    visibility: hidden;
	opacity: 0;
}
}

ย 

Email meย if you have need any help (free, of course.). Answer within 24 hours.ย 
Or send to forum message

Contact Customer Careย - Learn CSSย - Buy me a coffeeย (thank you!)

Link to comment
  • 1 year later...
On 9/5/2024 at 5:01 AM, EmilyBrimmer said:

Was there ever a solve here? Trying to accomplish the same thing with revolutionmotherhood.com

You can use this to Website Tools > Custom CSS

section[data-section-id="66ca56fc0861cf3e4cb4561d"] .section-border img {
	opacity: 0 !important;
	visibility: hidden !important;
}

ย 

Email meย if you have need any help (free, of course.). Answer within 24 hours.ย 
Or send to forum message

Contact Customer Careย - Learn CSSย - Buy me a coffeeย (thank you!)

Link to comment
On 9/7/2024 at 5:01 AM, tuanphan said:

You can use this to Website Tools > Custom CSS

section[data-section-id="66ca56fc0861cf3e4cb4561d"] .section-border img {
	opacity: 0 !important;
	visibility: hidden !important;
}

ย 

This doesn't *quite* accomplish what I'm looking for, because it also disables the fallback on mobile.ย ย 

Link to comment

For external videos like Vimeo/YouTube, I used this code to show the website logo while the background video was loading.

This is for the first section of the page.

You can adjust the width and height if you want to show a larger image rather than the logo.

ย 

#sections > :first-child .sqs-video-background:has(.c-background-video:not(.is-ready)):before {
    content : "";
    width: 200px;
    height : 102px;
    background: url("your-image-link-here") no-repeat;
    position : absolute;
    top : 50%;
    left : 50%;
    transform :translate(-50%, -50%);
}

ย 

ย ๐Ÿ‘จโ€๐Ÿ”ง๐Ÿ‘จโ€๐Ÿ’ปย Squarespace plugins

๐Ÿ™‹โ€โ™‚๏ธย Squarespace Custom Web Development & Design Services

๐Ÿ“…ย Todoist alternative | Increase your Productivityย 

๐Ÿ“นย Squarespace Tutorials for free - YouTube๐Ÿ“นย 

๐Ÿ’ฏ๐Ÿš€ I have worked on over 300 Squarespace sites with custom code for over 9 years

๐Ÿ™‹โ€โ™‚๏ธย Let's connect on LinkedIn

ย 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

ร—
ร—
  • Create New...

Squarespace Webinars

Free online sessions where youโ€™ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.