Skip Navigation

[Gelöst] Dynamic Video Source Block not working

This support ticket is created vor 1 Jahr, 8 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 Antworten, has 2 Stimmen.

Last updated by MargeP6083 vor 1 Jahr, 8 Monate.

Assisted by: Luo Yang.

Author
Artikel
#2435273

Similar to this thread: https://toolset.com/forums/topic/toolset-video-block-cannot-specify-dynamic-source/

I need a dynamic video block since some of our members use incorrect configuration for their video urls. For example, instead of adding a url to a youtube video, they will add a channel url. On their post, [types field='video'][/types] appears as a raw url to their YouTube channel, consequently no video appears.

I'm not able to add a dynamic source as the Toolset video block is now. (I'm not sure why the dynamic option is available if the block doesn't do dynamic source.) I was hoping this would solve the problem and there would be an error for the user to see on the front end when they viewed their post.

I need a solution to users adding incorrect urls to youtube or vimeo that don't show a video, but show channels or are incorrect format.

Thanks in advance!

#2435541

Hello,

It is different case, your case is using wrong embedded video URL.
There isn't such kind of built-in feature to valid the embedded video URL with Toolset plugins, you might consider other workaround, I have searched it in Google, found some related posts, for example:
https://stackoverflow.com/questions/1362345/check-if-youtube-and-vimeo-clips-are-valid

For your reference.

And I suggest you review the new posts and embedded video URL before you publish the post.

#2435553

Is it possible to use the shortcode to check if the url contains specific text, something like this?

[wpv-conditional if="( !CONTAINS($(video),'channel') )"][types field='video' width='640' height='360'][/types][/wpv-conditional]

Is there any documentation on the dynamic nature of the Toolset video block?

Thanks!

#2435671

There are some misunderstandings:
1) Toolset custom video field stores video file URL, it is different from custom embedded URL
2) Toolset embedded media field, stores URL of specific online video provider URLs, see WP document:
https://wordpress.org/support/article/embeds/

You can not use custom video field to store the embedded media URL

As I mentioned above, you can use custom codes to check it is a valid embedded media URL, for example:
1) Create a custom embedded field "video"
2) Create a custom shortcode to check if it is valid embedded URL, add below codes into your theme file "functions.php":

add_shortcode('valid_embedded_url', function($atts, $content){
	$atts = shortcode_atts( array(
        'field' => 'video',
    ), $atts);
	$url = get_post_meta(get_the_ID(), 'wpcf-' . $atts['field'], true);
	$res = 0;
	$oembed   = new WP_oEmbed();
	$provider = $oembed->get_provider( $url, [ 'discover' => false ] );
	if ( false !== $provider ) {
		$res = 1;
	}
	return $res;
});

3) Dashboard-> Toolset-> Settings-> Front-end Content, in section "Third-party shortcode arguments", add the shortcode name: valid_embedded_url
4) Use above shortcode in wpv-conditional shortcode, like this:

[wpv-conditional if="('[valid_embedded_url]' eq '1')"]
<p>[types field='video'][/types]</p>
[/wpv-conditional]

[wpv-conditional if="('[valid_embedded_url]' eq '0')"]
<p>incorrect format</p>
[/wpv-conditional]
#2436321

This works great! Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.