0
votes

I have a semi complicated flexible content component that accesses a postObject which includes an oembed ACF field.

In other words Flexible Content -> PostObject -> OEmbed

But I'd like to extract the raw OEmbed link to put into its own "A tag" that will send people to the video source.

I've looked at these issues:
https://github.com/timber/timber/issues/1211
https://github.com/timber/timber/issues/1423

which are similar, but don't seem to be working in my case.

Is there a way to
A) Pull out the link in the Twig template or
B) Extend Timber to return just the link somewhere in the PostObject?

1

1 Answers

0
votes

I would suggest extracting the link in you php and then adding it to context:

// Load value.
$iframe = get_field('oembed');

// Use preg_match to find iframe src.
preg_match('/src="(.+?)"/', $iframe, $matches);
$src = $matches[1];

// Add to timber/twig context
$context['iframe_src'] = $src