0

I have a video iframe it's can be youtube , vimeo etc

  $iframe = get_field($field, $id);
                if(empty($iframe)){
                  return;
                }
                preg_match('/src="(.+?)"/', $iframe, $matches);
                $src = $matches[1];
                $params = array(
                    'controls' => 1,
                    'hd'       => 1,
                    'autohide' => 1,
                    'autoplay' => $set_auto,
                );
                apply_filters( 'video_parameters', $params );
                $new_src = add_query_arg($params, $src);
                $iframe  = str_replace($src, $new_src, $iframe);
                $attributes = 'frameborder="0"';
                $iframe     = str_replace('></iframe>', ' ' . $attributes . '></iframe>', $iframe);                
                echo $iframe;

As per documentation i have to use this wp_filter_oembed_result() but i dont know how ..please help

  • To do what? What are you trying to do? – Jacob Peattie Sep 20 '19 at 2:44
  • @JacobPeattie escape iframe generated at the last line – Latheesh V M Villa Sep 20 '19 at 9:59
  • What, why? That doesn't make any sense. – Jacob Peattie Sep 20 '19 at 10:08
  • @JacobPeattie oh.. is it okay to echo iframes without escaping? esc_html() wont work.. – Latheesh V M Villa Sep 20 '19 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.