Controls
File
File control is used to upload file and store an array value with file info for the block. This control uses the native WordPress Media Popup to handle the upload and selection process. See examples below to use this control.
File control saves data as an array and contains the following keys:
Name | Description |
---|---|
id | Unique ID of uploaded file |
url | URL to access the file |
alt | Optional alt attribute used in <img> tags |
caption | Optional caption |
link | Link to file |
Control Settings
- Allowed Mime Types – limit the file type select by mime types. For example - allow only
jpg
andwebp
Usage
PHP
<audio src="<?php echo esc_url( $attributes['control_name']['url'] ); ?>" controls>
</audio>
Handlebars
<audio src="{{control_name.url}}" controls>
</audio>
Post Meta
$file = get_lzb_meta( 'control_meta_name' ); ?>
<audio src="<?php echo esc_url( $file['url'] ); ?>" controls>
</audio>