Jump to content

How do I add videos to an accordion menu on the personal plan?

Recommended Posts

  • Replies 7
  • Views 2.1k
  • Created
  • Last Reply

Top Posters In This Topic

Posted

First, add a Markdown Block under Accordion Block > Paste this code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(() => {
const list = $('.accordion-block p:contains("mp4")');
    for (let i=0; i<list.length; i++) {
        const link = $(list[i]).text()
        $(`<video src="${link}" loop autoplay>${link}</video>`).insertAfter(list[i])
    }
for (let i=0; i<list.length; i++) {
        $(list[i]).remove()
    }
})
</script>

Next, edit First accordion >> Paste video URL (mp4)

image.png.d6a41a70dd59f759b05381dd04515087.png

Result

image.thumb.png.93e5c45395d46b02b1011207a7040fa7.png

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!)

  • 2 weeks later...
Posted

For some reason this isn't working for me. I have added the markdown block underneath the accordion block. 

Perhaps it is because I have updated to the next level higher than the personal plan (the business plan?)

Here is the website: https://www.benscott.actor/

password: abc

Also, do I have to host the .mp4 file at a specific URL, or can it be on Vimeo? Please let me know! Thanks

Posted
On 12/31/2023 at 1:56 AM, graphicultra said:

For some reason this isn't working for me. I have added the markdown block underneath the accordion block. 

Perhaps it is because I have updated to the next level higher than the personal plan (the business plan?)

Here is the website: https://www.benscott.actor/

password: abc

Also, do I have to host the .mp4 file at a specific URL, or can it be on Vimeo? Please let me know! Thanks

You need to host mp4 somewhere (you can upload to Squarespace) to get video direct url

With Vimeo, you need to use paid plan to get direct video url

 

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!)

Posted

Awesome! It is working. Is there any way for the user to pause, or have any playback controls for the video? It seems to just be looping from the second the accordion tab is opened. 

  • 8 months later...
Posted

Hi Tuan -- Can you help me understand what you mean by, "First, add a Markdown Block under Accordion Block " ?

I hope to place an embedded video into my accordion, but was unable to figure out where to put that code you offered.

 

Ty!

Posted
On 10/2/2024 at 1:05 PM, Sissily said:

Hi Tuan -- Can you help me understand what you mean by, "First, add a Markdown Block under Accordion Block " ?

I hope to place an embedded video into my accordion, but was unable to figure out where to put that code you offered.

 

Ty!

Use Markdown if you have Personal Plan, but if you use Business Plan/higher, no need to add it.

Also, I wrote this new guide, you can follow it

 

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!)

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.