Support

Account

Home Forums General Issues oEmbed button color

Solved

oEmbed button color

  • Hey there,

    I have some Vimeo videos added through ACF’s oEmbed feature.

    ACF generates the following code:

    <iframe title="Welsh Family Hawaii" src="https://player.vimeo.com/video/319395748?dnt=1&app_id=122963" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen="" id="iFrameResizer2" scrolling="no" style="overflow: hidden;"></iframe>

    Which needs to be:

    <iframe title="Welsh Family Hawaii" src="https://player.vimeo.com/video/319395748?dnt=1&color=#ff0000&app_id=122963" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen="" id="iFrameResizer2" scrolling="no" style="overflow: hidden;"></iframe>

    I added a color argument, which changes the button background color from the Vimeo blue to a red. Is there any way through a function or through some jQuery to get &color=#ff0000 added to the code the plugin generates?

    The page I am working with is: https://isbellfamilyfilms.com/products/

    Thanks,
    Josh

  • So, I posted this before I found: https://www.advancedcustomfields.com/resources/oembed/

    The section entitled “Display value with additional attributes” is the exact code I am using. I can now control the button color 🙂

    The code I am using looks like:

    <?php
    $video = get_sub_field('video');
    
    preg_match('/src="(.+?)"/', $video, $matches);
    $src = $matches[1];
    
    $params = array(
    'color' => f1d925
    );
    
    $new_src = add_query_arg($params, $src);
    $video = str_replace($src, $new_src, $video);
    
    $attributes = 'frameborder="0"';
    $video = str_replace('></iframe>', ' ' . $attributes . '></iframe>', $video);
    
    echo '<div class="video">'.$video.'</div>';
    ?>

    Thanks,
    Josh

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘oEmbed button color’ is closed to new replies.