WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #26386, comment 11


Ignore:
Timestamp:
01/28/2014 03:30:05 PM (8 years ago)
Author:
helen
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26386, comment 11

    initial v1  
    11I uploaded a patch 26386.2.diff​ that adds the filter I was talking about. Here is example usage:
    22
    3      add_filter('custom_background_style', 'slug_full_screen_bg', 10, 2 );
    4      function slug_full_screen_bg( $style, $background ) {
    5      if ( $background != '' ) {
    6      $style = "background-repeat: no-repeat; -webkit-background-size: cover;-moz-background-size: cover;-o-      background-size: cover;background-size: cover;background-attachment:fixed;background-position:center;";
    7      $style .= " background-image: url('$background');";
    8      }
    9      return $style;
    10      }
     3{{{
     4#!php
     5add_filter('custom_background_style', 'slug_full_screen_bg', 10, 2 );
     6function slug_full_screen_bg( $style, $background ) {
     7    if ( $background != '' ) {
     8        $style = "background-repeat: no-repeat; -webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover;background-size: cover;background-attachment:fixed;background-position:center;";
     9        $style .= " background-image: url('$background');";
     10    }
     11    return $style;
     12}
     13}}}
    1114
    1215This example, to be used in a theme or plugin, creates a full-screen background if an image is set in custom backgrounds, and just outputs the background-color rule and value if none is set.