This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Not able to control video size with oembed

  • Creator
    Topic
  • #15952
    Eleven Sites
    Participant

    Hi Jason,

    I’m trying to pull in a custom field on a custom post type template, which is set up to allow multiple instances. It’s a YouTube video URL field. Anyway, I’ve not been able to pull in the field through the template and display it at the specified size, though the videos do display.

    So, I’m testing it by plopping the codex example for wp_oembed_get (http://codex.wordpress.org/Function_Reference/wp_oembed_get) directly into my template file, but it’s still showing the video at 100%.

    $video_embed = wp_oembed_get('https://www.youtube.com/watch?v=nCjsWpM9zFU', array('width'=>200, 'height'=>200));

    I’ve also added the following filters that I saw you post on another thread (regarding Alyeska), and these didn’t change my ability to control the video size.

    add_filter( 'themeblvd_the_content', array( $wp_embed, 'run_shortcode' ), 8 );
    add_filter( 'themeblvd_the_content', array( $wp_embed, 'autoembed'), 8 );

    Can you help me with this dilemma?

    Cheers,

    Lindsay

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #15958
    Jason Bobich
    Keymaster

    I’m trying to pull in a custom field on a custom post type template, which is set up to allow multiple instances. It’s a YouTube video URL field

    Within your main loop, you’d do this:

    $video_url = get_post_meta( get_the_ID(), 'field_name', true );

    https://codex.wordpress.org/Function_Reference/get_post_meta

    So, I’m testing it by plopping the codex example for wp_oembed_get directly into my template file, but it’s still showing the video at 100%.

    The framework filters all oEmbed output to be responsive. This means that the videos will always be 100% width of the containers they sit in, ignoring the actual embed width. Then this allows for the videos to scale naturally down as the browser viewport gets smaller.

    Like everything in the framework, these filters can be removed, which would allow for videos to display as WordPress does by default. However, I would not suggest this because then your going to have responsive issues with embedding videos.

    The quick solution would just be to output the video in some sort of DIV or other HTML element which contains some sort of maximum width.

    For example:

    .video-thumbs {
    	max-width: 200px;
    }
    <div class="video-thumbs">
    	<?php echo wp_oembed_get( get_post_meta( get_the_ID(), 'field_name', true ) ); ?>
    </div>

    I’ve also added the following filters that I saw you post on another thread (regarding Alyeska), and these didn’t change my ability to control the video size.

    I’m not quite sure how this is relvant to anything you’re doing. This is essntially going to allow you to use oEmbed of the “Content” and “Columns” element of our Layout Builder plugin.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.