Display the converted video instead of the original
I ended up building another shortcode that returns directly the URL of the converted file, but it does not work inside the source tag, while it works alone. Check this screenshot hidden link
<video class="single-video" controls="" autoplay="">
<source src='[converted-media-url]'>
</video>
[converted-media-url]
So, I tried to build another shortcode that produces the whole video tag, but it still does not work. So, I built another shortcode that uses the plugin's one rt_media. But it does not generate only the URL, it also generates the video player. The final code is:
function converted_media_player_func( $atts ) {
global $post;
$id = media_info_func( array() );
return do_shortcode( '[rt_media attachment_id="' . $id . '"]' );
return $results;
}
add_shortcode( 'converted-media-player', 'converted_media_player_func' );
function media_info_func( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'field' => 'wpcf-video-upload',
),
$atts
);
global $post, $wpdb;
$field = $atts['field'];
$info = $atts['info'];
$media_url = get_post_meta( $post->ID, $field );
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $media_url ));
$attachment_id = $attachment[0];
return $attachment_id;
}
add_shortcode( 'types-media-id', 'media_info_func' );
And can be used like:
The result is the plugin's video player: hidden link
Please note, that this is custom code, and is therefore out of the scope of the support forum. If you are not comfortable with programming, consider hiring a developer. We have a list of partners here https://toolset.com/contractors/
Thank you Jamal, thats solved it! I've now got both the video and the link to the video.
Perfect. Many thanks for all the work you've put into this. It much appreciated!
Best regards
James