Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoPress download block #42

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open

Conversation

verytwisty
Copy link
Collaborator

@verytwisty verytwisty commented Feb 18, 2025

As part of the a project I was asked to create a Download button for a VideoPress video. This functionality exists within the iFrame of the VideoPress block but it's not obvious where this button is because it is hidden inside a modal, and the modal trigger button is only visible when hovering over the video.

  • This block works by checking if there are any VideoPress blocks on a post / page
  • If there are none, a message No VideoPress block found is displayed on the backend and nothing is displayed in the front end
  • If there is one VideoPress block on the page it will get the attributes needed to build the download url on the front end from that VideoPress block.
  • If there is more than one VideoPress block on the page a dropdown appears in the sidebar enabling the user to select which video they want the button to download.
  • The selected video will have to have the allow download button checked otherwise a Download is disabled for this video message is displayed in the backend and nothing is displayed on the front end
  • Both private and non-private videos can be downloaded with this button
  • For private videos we need to get the token that is saved in local storage to create the url. The code for this often loads after our script so we have a setInterval that runs up to 15 times to check whether the local storage has been set.
  • If the url for the public and url and token for the private are not set the button shows anVideo cannot be downloaded error on the front end.

Due to the way this block works, it is not possible to use it with synced patterns or FSE templates.

Please note I also used the __experimentalBorder property in the block.json because the button would work better with this enabled, but let me know if you would like me to take this out

@verytwisty verytwisty self-assigned this Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant