Download Media from WordPress

This feature allows you to add a link to any WordPress page that will download media to the app that can be accessed offline.

This feature can be used to download course materials in a LearnDash app, or download video or audio on any post or page.

How is this different from the media list with downloads?

The media list uses a WP-API route, and gets the download url from post meta. The feature described on this page is for WordPress (iframe) pages, and the download link is added in the WordPress post editor.

Video Tutorial

Usage

To add a download link, visit any WordPress post or page on your site. Add a link that looks like this:

<a class="button app-download" href="https://mysite.com/wp-content/uploads/2018/12/my-media.mp4" data-download-title="Champion">Download Champion</a><br>

Attributes:

  1. class of "app-download" - this tells the app to download the media
  2. href - path to the media file
  3. data-download-title - title of the download, used to display in the app

Add the page to your app by visiting your app customizer => Menus => Add Item => WordPress/external link. Note: you cannot test downloads in the preview, you must build the app for your device.

Next you need a place to display the downloads in the app.

Display Downloads in App

Now that the file has been downloaded, you need a place to display it in the app.

In your app customizer, create a new Custom HTML page, and add this code:

    <ion-item (click)="showDownloads()">
    <ion-icon name="download" item-left></ion-icon>
    Show Downloads
    </ion-item>

You can change the markup, the important thing is the (click)="showDownloads()" part. That opens a modal that displays the downloads.

The user can click that button, then play the media that has been downloaded.