Skip to content
Controls

File

File control lets you upload and select files using the WordPress Media Library. The control stores file information as an array.

File Control

Control Settings

  • Allowed Mime Types - Limit allowed file types (example: jpg, webp)

Saved Data

The control saves the following file information:

NameDescription
idUnique ID of uploaded file
urlURL to access the file
altOptional alt attribute used in <img> tags
captionOptional caption
linkLink to file

Usage

PHP
<audio src="<?php echo esc_url( $attributes['control_name']['url'] ); ?>" controls>
</audio>
Handlebars
<audio src="{{control_name.url}}" controls>
</audio>
Post Meta
<?php
$file = get_lzb_meta( 'control_meta_name' );
?>
<audio src="<?php echo esc_url( $file['url'] ); ?>" controls>
</audio>

The control uses the native WordPress Media Library for file uploads and selection.

Was this article helpful?