WordPress.org

Ready to get started?Download WordPress

Forums

$content_width in a responsive theme (9 posts)

  1. lenzjo6754
    Member
    Posted 1 year ago #

    What should I do about:

    code 'if ( !isset( $content_width ) ) $content_width = 610;'

    when creating a responsive theme? Because there is no knowing what the width of the page will be.

  2. Yakir Gottesman
    Member
    Posted 1 year ago #

    Same question.

  3. piggy017
    Member
    Posted 1 year ago #

    anyone find out the solutions yet?
    having the same prob here :(

  4. paulwpxp
    Font hero
    Posted 1 year ago #

    $content_width only used in oEmbed. It determines the size of embed content like youtube.
    http://codex.wordpress.org/Embeds

    See functions.php of Twentytwelve on how to change $content_width based on theme layout.

  5. Yakir Gottesman
    Member
    Posted 1 year ago #

    Yes, but what about responsive themes?

  6. paulwpxp
    Font hero
    Posted 1 year ago #

    I use this plugin with great result.

    Responsive Video Embeds
    http://wordpress.org/plugins/responsive-video-embeds/

    There is also JS solution fitvids.js, but I prefer non JS

  7. alchymyth
    Forum Moderator
    Posted 1 year ago #

    responsive themes usually have a max width - adjust the $content_width to fit that max width; smaller screen sizes should then adjust automatically.

  8. Tevya
    Member
    Posted 1 year ago #

    I'm not sure I'm following you @alchymyth. Could you explain in more detail?

    It seems like there should be a way to set $content_width to a max pixel width, but still have it responsive to the available space. However, I haven't been able to find anything that explains how you'd go about doing this.

    EDIT: found some agrement that this sucks: http://wycks.wordpress.com/2013/02/14/why-the-content_width-wordpress-global-kinda-sucks/

    I also found out the 2012 theme makes the new WP 3.6 player very responsive. It's not a problem there. But I can't find anything about how they did it. And the YouTube player is not very responsive, the width of the video player changes, and the video itself resizes nicely, but the height of the player doesn't change (at least when dragging the browser size).

  9. xlp
    Member
    Posted 11 months ago #

    I have the same question. And I found one more anoying thing, I set in media preferences 2 sizes for the images (Medium and Large), but as i have a responsive theme and want to supply 2x images for retina displays my images are double in size, so my Large image size is 1600px and then with css is set to 50% of this size to look as 800px. I found that if I have a $content_width= 900 the size Large is no longer 1600px, is automatically set to 900, the medium size is not modified and is 1200px (bigger than the content–width). So i removed the $content_width function…

Topic Closed

This topic has been closed to new replies.

About this Topic