oEmbed Not Available - Get URL?

Support General oEmbed Not Available - Get URL?Resolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46620
    Andrew TegenkampAndrew Tegenkamp
    Participant

    I have a Meta Box with oEmbed and Clone on, and it works great in admin to add multiple videos to a custom post type. In display, I have one video that cannot use oEmbed and another that can. Using rwmb_the_value, it shows "Embed HTML not available." and then the second one works as a YouTube embed. I'd like to change the "HTML not available" to just be a link to the video in a new tab, but cannot get the video URL. I see this in the docs, but $message only seems to hold the original message.

    
    add_filter( 'rwmb_oembed_not_available_string', function( $message ) {
        $message = 'Sorry, what you are looking here is not available.';
        return $message;
    } );

    Is there a way to change the message to make it a link when oEmbed is not available? I'm fine looping through the Meta Box array if I need to do that, but I'm just not sure what's the best way here.

    #46621
    Andrew TegenkampAndrew Tegenkamp
    Participant

    Meant to add my current solution is to get the array with rwmb_get_value and loop it with WP's built in wp_oembed_get, so please update this if there is a better way:

    
    $url = rwmb_get_value( 'view_kids_oembed' );
    printPre($url);
    foreach ($url as $link) {
    	$embed = wp_oembed_get($link);
    	if ($embed) {
    		echo $embed;
    	} else {
    		echo '<a href="">'.$link.'</a><br>';
    	}
    }
    
    #46638
    PeterPeter
    Moderator

    Hello Andrew,

    There is only one variable $message (text) is passed to the filter hook rwmb_oembed_not_available_string so it isn't possible to add a link to the URL if it isn't available. I will inform the development team to consider adding the URL variable to the filter hook.

    Thanks for sharing your solution.

    #46869
    Anh TranAnh Tran
    Keymaster

    This is done and will available in the next version.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.