Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#32403 closed enhancement (maybelater)

Provide ability to crop background image

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Customize Keywords: needs-patch close
Focuses: administration Cc:


When I upload a header image I'm given the option to crop it. Not so for the background image. There's no reason not to allow cropping of the background image.

Change History (10)

#1 @celloexpressions
9 years ago

  • Version set to 3.9

Should be pretty easy to do once we do #29211. But #29211 will likely be difficult.

This ticket was mentioned in Slack in #core by celloexpressions. View the logs.

9 years ago

#3 @celloexpressions
9 years ago

Proposed this as a feature-plugin, pending completion of #29211 for full functionality:

This ticket was mentioned in Slack in #core by celloexpressions. View the logs.

8 years ago

#5 @kirasong
8 years ago

After chatting with a few folks, it seems like this is probably more of a standard enhancement than a feature plugin.
@celloexpressions, would you mind posting a patch here for review?

This ticket was mentioned in Slack in #core by mike. View the logs.

8 years ago

#7 @celloexpressions
8 years ago

My thoughts on this are as follows:

  • We can add cropping to background images very easily if we want to, with WP_Customize_Cropped_Image_Control.
  • I'm not sure whether or not this belongs in core. If we add cropping, every user will have to at minimum make an extra click to "skip cropping" before they can set a background image. Will 80% of users use this feature?
  • Background images need some work as a feature. There are too many options available, and much depends on things like screen size that users may not know to test. Introducing background image cropping without first supporting things like the background-size property could be confusing, as the visual part of an image could differ significantly from the crop. But because there are already so many different options here, it may be necessary to explore a broader rethinking that moves away from options for specific css properties to more generalized formats such as "tiled", "full-screen (covered)", "full-screen (contained)", etc.
  • Whether before or after adding cropping, there is an opportunity to add a "library" feature for background images that displays several previously uploaded images, like headers do. The custom header image code (which does not utilize any other core customizer controls) first needs to be eliminated and brought into WP_Customized_Cropped_Image_Control or a more generic subclass of that control that includes "uploaded" capabilities.

#8 @Fab1en
8 years ago

I agree with @celloexpressions : cropping a background image is not just about using WP_Customized_Cropped_Image_Control. It's much more likely for a background image than for a header one to not be displayed in full, or to appear in full width but not full height. Today it's tricky to manage this case with the cropping tool in the customizer.

I think it would be better to let theme authors define it themselves. It's easy to redefine the default background image customization and use WP_Customized_Cropped_Image_Control where needed. In my opinion, it's not useful to change the behavior of the background image feature defined by default.

One possibility to introduce this change without too much noise, would be to add a new parameter to the add_theme_support call :

$defaults = array(
        'default-color'          => '',
        'default-image'          => '',
        'default-repeat'         => '',
        'default-position-x'     => '',
        'default-attachment'     => '',
        'wp-head-callback'       => '_custom_background_cb',
        'admin-head-callback'    => '',
        'admin-preview-callback' => '',
        'allow-cropping'         => false,
add_theme_support( 'custom-background', $defaults );

#9 @celloexpressions
8 years ago

  • Keywords close added

Thinking we should close this as maybelater. Background images could use some broader changes as noted above, and the usefulness of cropping in particular could be reevaluated when that happens. In the meantime, the plugin is available for users that want this functionality, but with 100 active installs, there seems to be some demand for it but not enough to justify core inclusion yet:

#10 @celloexpressions
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Closing in favor of the plugin.

#22058 now contains a refresh of custom backgrounds that adds support for background-size. But even with background-size support, there are too many variables to consider when setting up a background that will impact how much, if any, of an image is visible. Prominently supporting cropping as part of the background-upload flow is a false promise to users about what part of their image will be visible. There are plenty of ways to crop a background image currently, including cropping before uploading, cropping via the edit image functionality in the media modal, or using the plugin linked above.

Note: See TracTickets for help on using tickets.