WordPress.org

Ready to get started?Download WordPress

Forums

How can Authors center video Embeds in a Twenty Ten child theme? (5 posts)

  1. X-Maj
    Member
    Posted 1 year ago #

    I've noticed that the [embed] shortcode allows youtube video resizing, but not alignment. My wordpress site has several Authors now and i'd like their embedded videos to be centered in their posts, but obviously they can't use unfiltered HTML to do this.

    I have a Twenty Ten child theme set up with a few basic changes in the style sheet. What change would i have to make to center all embedded videos?

    Also, is there a way to disable youtube options such as "Show suggested videos when the video finishes"? Normally that's done by adding "?rel=0" to the video URL in the iframe code, but adding that to the URL in wordpress makes auto-embed stop working.

    Thanks in advance!

    [ Please do not bump, it's not permitted here. ]

  2. X-Maj
    Member
    Posted 1 year ago #

    I don't really know what i'm doing so this is probably super clumsy, but adding this line to my stylesheet seemed to work:

    #content .entry-content iframe { display: block; margin: 0 auto; }

  3. Andrew
    Forum Moderator
    Posted 1 year ago #

    It depends on your code, but in general, margin: 0 auto (as long as the element is displayed block) does centre your element (within its parents element).

    Could you link to your website if this doesn't work?

  4. I've noticed that the [embed] shortcode allows youtube video resizing, but not alignment.

    Works for me just know. Is your child theme importing the parent theme's CSS?

    Try surrounding your YouTube link with [embed] like so

    [embed]http://www.youtube.com/watch?v=dQw4w9WgXcQ[/embed]

    Then use the visual editor to center the line. The HTML editor view will show that as

    <p style="text-align: center;">[embed]http://www.youtube.com/watch?v=dQw4w9WgXcQ[/embed]</p>
    <p style="text-align: left;">How's this work?</p>

    The style="text-align: center;" should take care of it. I added the <p style="text-align: left;"> afterwards to out back left text alignment.

  5. X-Maj
    Member
    Posted 1 year ago #

    Andrew Nevins:
    Yeah, it works fine. The only clumsy part is that it'll probably center all iframes instead of just youtube embeds. If there's a way to make that line of code specific to youtube embeds, that would be cool.

    Jan Dembowski:
    Centering embeds from the visual editor or HTML editor only works if your account has Editor privileges or higher. It doesn't work for Author accounts.

Topic Closed

This topic has been closed to new replies.

About this Topic