New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Pre-post hook, modify before upload #26
Comments
Hi @maxmarkus , In the free version of the plugin, there is option to use Something like this: function my_dgv_backend_after_upload($params) {
$vimeo_id = $params['vimeo_id'];
// Do your logic...
}
add_action('dgv_backend_after_upload', 'my_dgv_backend_after_upload'); At this time the plugin API does not include utilities for folder management, but i will think for a way to include those methods in both free and premium versions. Best Regards, |
Hi @gdarko Thank you for your response, I am not sure if this is what I was looking for. I checked the code and I think it would be a Using the premium version btw. So, would it be possible to add Best regards, |
Hi @maxmarkus Thanks for the information. Just wanted to ask, which APIs you are using? For example, I can add those hooks when the process is done through the backend (using PHP) e.g when using the frontend upload. However, I can't add those hooks when using the Gutenberg/TinyMCE upload because those are handled entirely via JavaScript. If WordPress has some action/filter system for JavaScript I will add those for the Gutenberg/TinyMCE elements. Best Regards, |
Hi @gdarko Using the Vimeo custom post type that is available in the backend. Not using any Gutenberg/TinyMCE, since my CPTs are built with standard ACF fields, where I can use a "relation" to get Vimeo entries.
Edit: I see that
Then the hook would only be available for the other use cases, which can be documented. Best, Markus |
@maxmarkus , I added the hook for the other use cases as of version 1.7.1 For example, different client requested to add a timestamp on the Video dates created from the front-end, This wasn't possible before 1.7.1 and you can see example here: /**
* Append date to the video title stored in Media > Library
*
* @param $args
*
* @return mixed
*/
function dgv_before_create_local_video_params_823842831( $args ) {
$args['post_title'] = sprintf( '%s - %s', $args['post_title'], wp_date( get_option( 'date_format' ) ) );
return $args;
}
add_filter( 'dgv_before_create_local_video_params', 'dgv_before_create_local_video_params_823842831', 20 );
/**
* Append date to the video title stored in Vimeo.com
* @param $args
*
* @return mixed
*/
function dgv_before_create_api_video_params_823842831( $args ) {
$args['name'] = sprintf( '%s - %s', $args['name'], wp_date( get_option( 'date_format' ) ) );
return $args;
}
add_filter( 'dgv_before_create_api_video_params', 'dgv_before_create_api_video_params_823842831', 20 ); Please note that you can still manipulate the Vimeo.com entries with the using /**
* Additional vimeo api manipulation after video upload.
*
* @param $args
*/
function dgv_backend_after_upload_823842831( $args ) {
$uri = wvv_id_to_uri( $args['vimeo_id'] );
$source = isset( $args['software']['source'] ) ? $args['software']['source'] : ''; // Possible values: Editor, Media Table, API::upload, API::uplod_pull
try {
$vimeo = new WP_DGV_Api_Helper();
$vimeo->set_video_folder( $uri, '/users/120624714/projects/2801250' ); // eg. /users/{user_id}/projects/{folder_id}
// Other calls..
// Eg. $vimeo->api->get()
// Eg. $vimeo->api->request()
} catch ( \Exception $e ) {
error_log( 'WP Vimeo Videos error: ' . $e->getMessage() );
}
}
add_action( 'dgv_backend_after_upload', 'dgv_backend_after_upload_823842831', 20 ); |
Thanks alot, I think that solves my requirements. Would close it for now and only reopen if I experience issues with the new feature. |
Hello,
I would like to see the possibility to modify the content before upload (and the other way around), since I would like to verify and change the payload before sending it to vimeo. Not talking about the video itself, but about the metadata.
My initial thought was about using a separate folder per user in vimeo, but that might be overkill.
Even if there are later maybe thousands of videos, at the end it should be enough to prefix the titles of a given user/entity with its id.
Therefore my wish would be two filters to modify the data before storing and after fetching it from vimeo.
Best, Markus
The text was updated successfully, but these errors were encountered: