WordPress.org

Make WordPress Core

Opened 2 years ago

#41403 new defect (bug)

Support "class" and "id" attributes on wp_oembed_get()

Reported by: ramiy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:
PR Number:

Description

The oembed function wp_oembed_get( $url, $args ) allows us to set additional arguments for retrieving embed HTML.

The problem is that currently the function supports two arguments, only width and height. In some cases developers need more flexibility, to set other HTML attributes like id, class and maybe even title (for better accessibility).


I was trying to thinking of an example and I think that the simplest example would be bootstrap responsive embeds.

<div class="embed-responsive embed-responsive-21by9">
  <iframe class="embed-responsive-item" src="https://..."></iframe>
</div>

Currently you can't set custom classes in iframe with the attributes:

wp_oembed_get( 'https://...', array( 'class' => 'embed-responsive-item' ) );

Change History (0)

Note: See TracTickets for help on using tickets.