-
Notifications
You must be signed in to change notification settings - Fork 4
Using MediaThèque from your plugin
What about relying on MediaThéque to handle your plugin's Media uploads needs ?
If you are using the WP_Editor within your plugin to allow front-end post type submissions for example, MediaThèque will automagically add an "Add User Media" button above your instance of the WP_Editor. You have nothing to do. Here's a screenshot about what happens with the bbPress topic form:
NB: as, by default, bbPress is using the Quicktags mode, to make the animation more visual, I've used a specific filter to use the visual editor instead.
You can also use the mediatheque_button() function with other regular text fields. Once the user will click on the Insert Media button, this text field will contain the User Media permalink. Here's an example that adds an "Add User Media" button to the BuddyPress activity post form:
The code used to achieve this is:
<?php
function mediatheque_button_activity_post_form() {
if ( ! function_exists( 'mediatheque_button' ) ) {
return;
}
mediatheque_button( array(
'editor_id' => 'whats-new',
) );
}
add_action( 'bp_activity_post_form_options', 'mediatheque_button_activity_post_form' );The editor_id argument is the ID of the regular text field you wish to use.
Get the latest MediaThèque release !

