• Sharon

    (@shpemu)


    Hi there! I’ve found a way to hack my current install to include vertical alignment for backgrounds, however I’d love to know how to add this to my twentyeleven child-theme. Additionally, I’m making the formal request that this be added to the next version of WordPress.

    Here’s what I did:

    First, I altered the /wp-admin/custom-background.php file like this:

    (starting at line 139)
    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    (starting at line 223

    // BEGIN EDIT BY SHARON MURPHY 03/30/2012
    //		. ' background-position: top ' . get_theme_mod('background_position_x', 'left');
    		. ' background-position: ' . get_theme_mod('background_position_y', 'top') . ' ' . get_theme_mod('background_position_x', 'left');
    // END EDIT BY SHARON MURPHY 03/30/2012

    (starting at line 283)
    [Code moderated.]

    This works, which is great and all, but it would be wonderful if this were part of the WordPress Codex. 🙂

    Here’s the Custom Background screen in action, with edits as listed above.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    First, I altered the /wp-admin/custom-background.php file like this:

    Don’t do that. Please don’t edit core unless you know how to submit patches for trac. And please NEVER suggest other people, especially newbies, edit core. You will lose your changes when you update.

    Thread Starter Sharon

    (@shpemu)

    My apologies for that. Until this is included in a new release of WordPress, I’d love to know…

    1. Is there any way I can add this support to my twentyeleven child theme?
    2. How do I submit this as a request for the next release?

    Thank you,
    Sharon

    Eric Mann

    (@ericmann)

    Sharon, can you post your modified code to a Pastebin so we can see what you’ve done?

    Thread Starter Sharon

    (@shpemu)

    Sharon: when uploading a background image to TwentyEleven, there are options to set the tiling, repeating, and position. I can’t tell in your screenshot what’s different about yours.

    That being said, these are CSS changes that could easily be put into your child theme’s CSS file.

    Thread Starter Sharon

    (@shpemu)

    Norcross – As for positioning, you can only set the horizontal positioning (left, right, center). I’ve added another line in the Display Options to allow for vertical positioning of the background as well (top, middle, bottom). This is not a standard option with the TwentyEleven theme nor with the WordPress codex as it stands now.

    Hi Sharon,

    You mention that you’re trying to do this in a child theme — I’m assuming that means you’re hoping to use this in a specific site, and for that purpose it would be much, much easier to add your background in CSS rather than making core changes.

    Still, I like the idea of having this as an option in the custom background tool, and it would be worth finding out if others like it too; if you’re interested in learning to contribute to WordPress, something like this could be a great way to start. (And a couple of heads-ups if you do: we’re getting ready for 3.4 beta, so it’s very unlikely that anything new would get into core until at least 3.5; also, there have been a lot of changes to both theme.php and custom-background.php for 3.4, so you’d have to update your changes to work with trunk (aka the latest dev version), as well as learning to work with trac, make patches, and the like.)

    Thread Starter Sharon

    (@shpemu)

    I’ve added it to my CSS, yes, but the changes I’ve listed here have been in an effort to create one additional option on the theme Admin side.

    I’ll definitely look into posting this as a request for 3.5. Thanks! 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Support for Vertical Align Backgrounds’ is closed to new replies.