Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author edwardtownend

    (@edwardtownend)

    Hi there, please could you give some more details including your usage of the wp_embed_register_handler and the URL you’re trying to embed? I’ve just tested it with Spotify embeds using this code to register the handler https://gist.github.com/Viper007Bond/2417309 and it worked fine.

    Kind regards

    Thread Starter OrangeDesign

    (@orangedesign)

    Hi, thx for your reply, my wp_embed_register_handler is :

    wp_embed_register_handler( 'consonet', '#https://(?:www|video)\.conso\.net/(?:video/visionneuse_conso\.php|embedvideo/)\?videoDocIdy=([\d]+)($|&)#i', 'wp_embed_handler_consonet' );
    
    function wp_embed_handler_consonet( $matches, $attr, $url, $rawattr ) {
    
      $embed = sprintf(
          '<div style="width: 644px; height: 500px; position: relative; overflow: hidden;"><iframe style="position: absolute; top: -60px; left: -5px;" src="https://www.conso.net/video/visionneuse_conso.php?videoDocIdy=%1$s" width="644px" height="415px" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe></div>',
          esc_attr($matches[1])
          );
    
      return apply_filters( 'embed_consonet', $embed, $matches, $attr, $url, $rawattr );
    }

    I tried to embed the conso.net videos (french site) with link like: https://www.conso.net/video/visionneuse_conso.php?videoDocIdy=27294.

    As I said, with this code, it’s work on a wysiwyg field, but not with your plugin.

    Plugin Author edwardtownend

    (@edwardtownend)

    Hi there, I’ve looked into this a little more and it seems that wp_oembed_get(), which the plugin uses to get the embed code from the URL, only supports fully oembed compliant providers added using wp_oembed_add_provider(), rather than faking oembed via wp_embed_register_handler() as you’ve used. This doesn’t seem quite right to me however, I’d expect wp_oembed_get() to support either kind of provider, so I’ll keep looking into it.

    Plugin Author edwardtownend

    (@edwardtownend)

    A temporary fix you’d be able to implement yourself is to swap out the wp_oembed_get() calls for:

    global $wp_embed;
    $embed = $wp_embed->shortcode($args, $url);

    The two places to look for are line 13 on oembed-ajax.php and line 230 of oembed-v4.php. I’m not going to add it to the plugin yet because it would mean losing the ‘object’ return type.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_embed_register_handler’ is closed to new replies.