Steps for displaying a download button on a video using JavaScript

I am working on a Django project and have a video.html file for displaying videos.

The code I currently have is used to display the video, but I would like to change the appearance of the play button and add a download button similar to this https://i.sstatic.net/whupN.png

     <div class="row portfolio-container">
          {% for portfolio in portfolio %}

          <div class="col-lg-4 col-md-6 portfolio-item">
<a href="{{ portfolio.file.url }}" download>
              <video id="{{portfolio.id}}"  onclick="videoviews({{portfolio.id}})" class="video-js vjs-theme-forest"  controls preload="auto" width="360" height="264" data-setup="{}">

              <button class="btn"><i class="fa fa-download"></i> Download</button>

              <source src="{{ portfolio.file.url }}" type="video/mp4" >


              </video>
             </a>
              <div class="mx-auto my-1 col-lg-12 d-block" style="font-size: 10px;">
                <p class="float-left">
                  <span class="font-weight-bold">Uploaded by:</span> <a href="{% url 'profile' username=portfolio.user.username %}">{{portfolio.user}}</a>
                </p>

                 <p class="float-right">
                  <span class="font-weight-bold" id="views{{portfolio.id}}">{{portfolio.views}}</span>
                </p>
              </div>
          </div>

Here is a screenshot of the current video frame. https://i.sstatic.net/SCVDR.jpg I'm new to Django and Javascript, so any help would be appreciated.

Answer №1

To incorporate an anchor tag, you can use the following code:

<a href="{{ portfolio.file.url }}" download>Download</a>

If you want to embed a video within the anchor tags, you can try this approach:

<a href="{{ portfolio.file.url }}" download><video>.....</video></a>

Keep in mind that the video tag is used to display and play video files in HTML documents. However, if you prefer not to allow users to play the video at all, you can omit the video tag.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieving a singular data entry through ajax request

I have encountered an issue with my code. While using ajax to retrieve data, I am only able to get one field at a time. The value I receive is correct, so that's not the problem. It seems like there might be an issue with how my array is constructed. ...

Strategies for maintaining pristine Firebase child paths

I have a list of data that I want to structure in Firebase. However, I encountered an error: Error: Firebase.child failed: The first argument provided is not a valid path. Path names should not include ".", "#", "$", "[", or "]" characters and must be no ...

Steps to reset a previous interval and initiate a fresh one

I'm completely new to Node JS and my task is simple: I just need to clear the existing interval and set a new one every time a user clicks a button. I attempted to use global.clearInterval, but it didn't produce the desired result. function upd ...

How come my menu is not showing up in the same format as the code?

I'm struggling to make the menu align with the text logo. Every time I try, the menu ends up below the logo instead of beside it. Can anyone provide some assistance? nav{ width: 1330px; margin: 0px auto; } nav ul li{ text-transform: up ...

Is there a problem with my document.onload?

Currently, I am experimenting with a GreaseMonkey userscript and trying out something relatively straightforward; function test() { document.getElementById('elementhere').innerHTML = 'test'; } document.onload = test(); When I visit th ...

Guidance on redirecting and displaying the URL retrieved from an API response object in the browser using express and axios

Currently in the process of developing a payment gateway using the Paystack API along with Axios for managing HTTP requests. After thoroughly examining their API documentation and reviewing their Postman collection, I was able to grasp how to structure th ...

Export the Excel file with hyperlinks to HTML format so that they can be easily opened in a file explorer instead of a web browser

I've got an excel spreadsheet that contains links to local folders. In order to optimize its compatibility with various devices, I convert it to HTML format. Everything seems to be working smoothly, except for one minor issue - when clicking on the li ...

Steps to Remove JWT Authorized Information by Identifying Number

I am currently utilizing JWT to manage access control for an express and React ecommerce application. However, I am unsure about how to remove the currently logged in user from the application. I have attempted using arrow functions and a button onclick ha ...

Utilizing a Function's Return Value as a State in React - A Comprehensive Guide

Currently, I am delving into the realm of functional components within React and have crafted a simple piece of code that should output 'Nah' if the state value is at 0. However, there seems to be an issue as this functionality does not seem to ...

How to Restrict the Number of Rows Displayed in an Angular 4 Table

Currently, I am faced with a situation where I have a lengthy list of entries that I need to loop through and add a row to a table for each entry. With about 2000 entries, the rendering process is slowing down considerably. Is there a way to limit the disp ...

In PHP, validating a value stored in a database against one entered in a text box

My form consists of multiple text fields, with the number determined by the amount of data in a database. Both inputs are integers. I would like to set up a validation where an error is triggered if the inputted value exceeds the corresponding value in t ...

Develop a website using HTML and CSS for the front-end design, complemented by Java for the

I find myself at a standstill with a project I want to tackle, but unfortunately, my knowledge of modern web development, particularly full stack, is minimal. As a result, I am completely clueless on how to proceed. Here is what I am familiar with and what ...

Error in JQuery Document Ready AJAX function causing image to not load initially without a page refresh

Currently, I have a piece of customized code that extracts data from an XML file and uses this data to populate specific content on my webpage: $(document).ready(function() { $.ajax({ type: 'GET', url: 'config.xml?date=& ...

Using Google Earth or Cesium to display moving shapes on a map

I'm feeling quite puzzled at the moment and could really use some advice. My goal right now is to achieve a Satellite view of a random building, complete with the typical RoadMap/3D effect found on Google Maps: I also want to incorporate three.js to ...

In Mozilla Firefox, the form-control with select tag shows the text, while in Chrome, the same component does not display it

I am currently using Angular 5.x in combination with the select tag and optgroup, along with Bootstrap 4.1.x This is how my component.html looks like: <select size="15" class="form-control mr-4"> ...

JSON syntax error: "r" is not a valid token at the beginning position

Currently, I am in the process of developing a web server that is based on STM32 MCU. The workflow involves the browser sending a request to the MCU, which responds with a web HTML file. Users can then adjust parameters and use a form to submit them back t ...

Searching through an array for multiple values on the same key

I am currently working on dynamically generating a listview in jQuery. So far, I have been successful in creating the entire list dynamically. However, I now face the challenge of filtering, searching, or reducing my initial data: var recipes = [ { "name" ...

Set the style properties of one class to match the style properties of another class using JavaScript

I need to dynamically create a div using the Bootstrap panel for displaying it. The div's class will either be "panel panel-success" or "panel panel-danger" based on the server response, which can be either "success" or "failure." To assign the class ...

Tips for resolving the "unexpected token 0 in JSON at position 0" error: When does this error typically appear? What is the main cause behind this error message?

Firstly, I kindly ask for understanding as I am a beginner in learning about servers and how they work. I have been encountering the same error repeatedly and despite my efforts to research and understand it, I am still left confused as to the root cause o ...

Tips for utilizing field mapping for a nested item in TypeScript

I am working with two separate objects below, let response = { offer: { custom_fields: { job_title: 'engineer' }, starts_at: 'test', ...