The Must Have for WordPress
The Must Have for WordPress
×
  • Home
December 5, 2019
PHP WordPress

Get Metadata from WordPress Video and Audio files

by Martin Jost
No comments
2 min Reading Time
3.4 K Views
5 Score
4 Likes
Share on Facebook Tweet on Twitter Share on Linkedin Pin on Pinterest Send via E-Mail Send via WhatsApp

In addition to images, videos and audio files are other formats that we can upload to WordPress and make them accessible to users. Depending on the use case, it may be useful to get certain metadata from video or audio files to show more details for the user.

How can I get Metadata from a video file?

WordPress has an own wp_read_video_metadata() function that will help us in this case. However, this feature is only available in the WordPress backend by default. To get the video metadata on the frontend we create a small wrapper function.

First, we need the URL to the video file. This could e.g. “https://domain.com/video.mp4”. We can use a helper function to get metadata from WordPress videos like the following example:

IMPORTANT: To work with the above function, we need an additional function called wordpress_get_full_path_of_url(); which you find in the following article:

Get the absolute File Path (Document Root-Path) in WordPress

Which video metadata can we get?

The following example shows which metadata can be included in a video file in WordPress. However, a video does not always have to contain all of this data. Sometimes only a small amount of data is available. It depends on the file and how it was created and compressed.

How I can get Audio file metadata in WordPress?

WordPress already has an own wp_read_audio_metadata() function to get audio metadata. By default this feature is only available in the WordPress backend. So, in this case we also build a small wrapper function.

IMPORTANT: We also need to include the wordpress_get_full_path_of_url() function to get metadata from audio files in WordPress. To get this function, read the following article:

Get the absolute File Path (Document Root-Path) in WordPress

Which audio data can we get from a file?

To start we need the URL to the audio file. This could e.g. “https://domain.com/audio.mp3” be. With the helper function, we use from the example above, we can get the following metadata from WordPress audio files.

Last updated: December 5, 2019

Get Metadata from WordPress Video and Audio files Score: 5 / 5 (2votes)
Share on Facebook Tweet on Twitter Share on Linkedin Pin on Pinterest Send via E-Mail Send via WhatsApp
The Author
Published by
Martin Jost

View all posts by Martin Jost

Related Posts
M
Javascript Minify and compress Javascript files in PHP

Loading time is an important factor in search engine optimization and for the user experience. E ...

Read More
A
WordPress Add custom classes to the WordPress BODY tag

Anyone who develops their own theme with a customizable layout or settings a theme needs to add ...

Read More
A
WordPress Anonymize IP address of WordPress comments

In the context of the European privacy policy regulations some regulations for web page owners a ...

Read More
Read more
U
Previous Post
Use PHP to remove certain characters or words from a string
O
Next Post
Open Graph in WordPress einbetten, ohne Plugin
Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Imprint
  • Privacy Policy
© 2016-2022 - wphave - The Must Have for WordPress
Login

Lost your password?

RequiredEssential cookies enable basic functions and are necessary for the proper functioning of the website.
  • Name: Cookie Status
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user's web browser allows cookies.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): cookie_status
  • Duration: 1 Minute
  • Name: Cookie Consent
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user agrees to allow opt-in cookies or not.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): cookieconsent_analytics, cookieconsent_marketing, cookieconsent_status
  • Duration: 1 Year
  • Name: Like Button
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user has already gave a like for a specific post.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): like_btn_{POST_ID}
  • Duration: 21 Days
  • Name: Post Rating
  • Provider: Owner of this website
  • Purpose: Is necessary to check whether the user has already rate a specific post.
  • Privacy Policy: https://wphave.com/privacy-policy/
  • Cookie Name(s): rating_{POST_ID}
  • Duration: 7 Days
AnalyticsStatistics cookies collect information anonymously. This information helps us to understand how our visitors use our website.
  • Name: Google Analytics
  • Provider: Google LLC
  • Purpose: Google cookie for website analysis. Generates statistical data on how the visitor uses the website.
  • Privacy Policy: https://policies.google.com/privacy
  • Cookie Name(s): _ga, _gat, _gid
  • Duration: 2 Years