Media Editor Modal: call for testing

The addition of a free-form image cropper in the BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. Editor has been a long-standing feature request. A GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ experiment that integrates this and other image editing features in a “Media Editor Modal” is ready for testing and feedback.

What is it?

The Media Editor Modal replaces the existing inline cropping tool in the Block Editor. The modal pattern keeps the familiar Crop button entry point, and brings freeform and aspect-ratio cropping, flip, fine-grained and snap rotation, and metadata editing into one dedicated workflow.

Under the hood, the modal consumes a coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. collection custom tools and components that will eventually live in a WordPress package. This will remove the reliance on third-party cropping libraries.

Why the change?

Image cropping in the Block Editor hasn’t changed much since its introduction. The existing inline image cropper is built on top of the react-easy-crop library. This implementation has a couple of constraints:

  • it’s limited by what’s achievable in the editor canvas and block toolbar, and
  • the library itself has a narrow set of features.

Why build our own library? Well-maintained, open sourceOpen Source Open Source denotes software for which the original source code is made freely available and may be redistributed and modified. Open Source **must be** delivered via a licensing model, see GPL. alternatives that do most of what users expect are few and far between. Furthermore, there’s a general preference for a WordPress-native surface that:

  • has all the features we want “out of the box” such as aspect ratios, freeform cropping handles, intuitive zooming, flip and rotation,
  • includes all the usability features we’d expect such as touch and keyboard support, and
  • is extensibleExtensible This is the ability to add additional functionality to the code. Plugins extend the WordPress core software. in ways idiomatic to the WordPress ecosystem.

There was an attempt to build a custom, editor-first cropper component, but it was abandoned. Rather than developing separate, one-off flows across blocks, the Media Editor Modal aims to provide a consistent foundation for both a new Media Library experience and various editor contexts, and also serve as platform for building more sophisticated experiences later.

How to test

If you’re familiar with the Gutenberg plugin development environment, you can check out trunktrunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running "trunk", then you are on the latest revision. right now and enable the Media Modal experiment from the experiments page at /wp-admin/admin.php?page=experiments-wp-admin

Update: #78653 merged, which makes the modal the default experience. No requirement to enable any experiment.

The quickest way to test is via Playground. Here’s a link that loads up Playground with Gutenberg Trunk and the Media Editor Modal active:

Suggested testing flows

The steps are provided just in case you need structure. Don’t feel any need to follow any or all of them.

The important question is whether the modal is solid enough as a replacement for the Image block crop flow, and whether you notice any bugs, UXUX User experience gaps or unexpected behaviors.

Basic crop flow

  1. Open the modal from an Image block.
  2. Resize the crop area.
  3. Pan and zoom the image.
  4. Rotate or flip the image.
  5. Save.
  6. Confirm the block updates to use the edited image.

Details editing

  1. In a saved post with a title, upload or insert an image.
  2. Open the modal from the Image block.
  3. Switch to the Details tab.
  4. Confirm Author and Attached to fields are populated with your author handle and the current post’s title.
  5. Update alt text and caption.
  6. Save.
  7. Confirm the media item updates.
  8. Confirm the Image block updates when its existing alt/caption values were empty or matched the original media values.

Existing custom block values

  1. Add an Image block.
  2. Manually enter custom alt text or a custom caption in the block.
  3. Open the media editor modal.
  4. Change the attachment’s alt text or caption.
  5. Save.
  6. Confirm custom block-level values are not unexpectedly overwritten.

Keyboard

  1. Open the modal.
  2. Use Tab to move through the crop area, crop handles, toolbar controls, sidebarSidebar A sidebar in WordPress is referred to a widget-ready area used by WordPress themes to display information that is not a part of the main content. It is not always a vertical column on the side. It can be a horizontal rectangle below or above the content area, footer, header, or any where in the theme. controls, Save, Cancel, and Close.
  3. Use arrow keys to move or resize the crop area.
  4. Confirm focus is visible and does not get lost.
  5. Try undo/redo with keyboard shortcuts.
  6. Confirm Escape behaves as expected when there are unsaved changes.

Touch gestures

  1. On a touch device, open the modal from an Image block.
  2. Test drag panning, pinch zoom, and crop area handle dragging for responsiveness and smoothness.
  3. Ensure toolbar actions like rotate, flip, undo, redo, and reset are tappable.

Sharing your feedback

Comments on this post are a great way to share feedback, but if you’d like to jump into Gutenberg feel free to leave feedback on this tracking issue as it’s the main one covering current tasks for the experimental modal. We’d love to know for example:

  • Did the modal open where you expected it to?
  • Was cropping understandable without extra instruction?
  • Did anything feel slower, confusing, or broken?
  • Did the image tools, including Save and Cancel behave as you’d expect?

Out of scope

The goal is to make the basic crop/edit workflow solid first, not to ship every image editing feature. Some related work is still being explored separately, for example:

  • Manual pixel crop controls.
  • Restoring original image.
  • Improving undo/redo history states.
  • Broader image editor extensibility for image filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. and/or AI integration options.

Thank you for making it this far, and thanks in advance for testing.

Props to @andrewserong and @isabel_brison for helping to write this post.

#core-editor, #gutenberg, #media, #media-modal

Media meeting recap – June 29, 2017

Overview

This post is a summary of the latest weekly Media component meeting, which took place in #core-media on SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/, on Thursday, June 29 at 18:00 UTC. The purpose of these meetings are to move priority tasks forward, provide feedback on issues of interest, and review media focused tickets on TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress..

Attendees:
@joemcgill, @sergeybiryukov, @mikeschroder, @adamsilverstein, @desrosj, @azaozz, @karmatosed, @matias, @youknowriad, @mkaz, @joen.

Transcript: https://wordpress.slack.com/archives/C02SX62S6/p1498759231771175

Media + GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/

Our agenda this week focussed on getting a better understanding of the current product vision for working with media in Gutenberg in order to coordinate priorities and ensure future improvements to the media component align with the needs of the new editor experience.

The major takeaway from this conversation was that Gutenberg intends to handle the UIUI User interface flows for editing media within post content inside the editor itself rather than relying on the wp.media.frame modal for these actions. The image gallery blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. in Gutenberg is a good example of this change.

Editing gallery settings in the current media modal

The current screen in the media modal for editing gallery settings

 

Editing gallery settings in the Gutenberg sidebar

A preview of editing image gallery settings in the Gutenberg sidebarSidebar A sidebar in WordPress is referred to a widget-ready area used by WordPress themes to display information that is not a part of the main content. It is not always a vertical column on the side. It can be a horizontal rectangle below or above the content area, footer, header, or any where in the theme.

By handling post-level setting in the editor, people can immediately preview changes in the editor. This change reduces the burden of the current media modal to act primarily as media library, and as a way to manage media information that applies site-wide. This should also make it more clear when changes will affect a media item site-wide, which is a nice UXUX User experience win.

Some next steps

To prepare for this shift, we need to document the current flows that will need to be adjusted in order to support this separation between managing post-level data and site-wide media library data.

Additionally, the Gutenberg team asked for help creating blocks for additional media elements like video, audio, etc. The Gutenberg GitHubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged by the repository owner. https://github.com/ repo now contains a “media” label for collecting issues that relate to the media component.

Other housekeeping items

Earlier this week, @desrosj ran a separate bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. scrub focussed on new tickets on the Media component. We plan on running separate scrubs throughout the 4.9 release cycle. If you’re interested in helping with that effort, please contact @desrosj or @joemcgill on Slack.

#gutenberg, #media, #media-library, #media-modal

New Customizer Media Controls in 4.3 and 4.2

Over the past several releases, the CustomizerCustomizer Tool built into WordPress core that hooks into most modern themes. You can use it to preview and modify many of your site’s appearance settings. APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. has drastically improved its built-in media controls, empowering developers to leverage the power of the WordPress media management experience in themes and plugins with ease. WordPress 4.1 refactored the image and upload controls to leverage the media modal for the first time (see #21483). 4.2 abstracted this functionality to a new base media control class. And now in WordPress 4.3, we’ve added a control for cropped images. In this post, I’ll outline the recent changes in Customizer media controls and explain the differences between the available controls.

WP_Customize_Media_Control

Before WordPress 4.2, all Customizer media controls saved the file url to their corresponding settings. While this facilitates quick access when using the value of the setting in themes and plugins, it makes it more difficult to access other information about that attachment, such as its title/caption, mime type, or in the case of images, accessing specific image sizes.

WP_Customize_Media_Control was introduced to allow this paradigm to change while maintaining backwards compatibility for the existing WP_Customize_Upload_Control and WP_Customize_Image_Control, which now extend the media control class (see #29215). The media control will save the attachment id for the selected media file to the Customizer setting, rather than the file URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org. However, note that the default value of the setting must still be a URL, since a default attachment id doesn’t really make sense.

The media control can be used for any type of media, be it an image, audio, video, PDF document, or any other file format that your server supports. To restrict a media control instance to a particular type of content, use the mime_type parameter when adding the control:

$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'audio_control', array(
	'label' => __( 'Media Control (audio)' ),
	'section' => 'media',
	'mime_type' => 'audio',
) ) );

When working with a setting corresponding with a media control, the sanitize_callback should generally be absint(), since a numerical id is expected. When using get_option() and get_theme_mod(), functions such as wp_get_attachment_url(), wp_get_attachment_image(), wp_get_attachment_image_src(), and even get_post() are useful depending on your needs, with each function taking the attachment id (value of the setting) as a parameter.

The full power of WP_Customize_Media_Control is realized when the control is extended to implement additional custom functionality in a custom child control. WP_Customize_Cropped_Image_Control is a great example of this in coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress.. The core Customizer control classes provide several working examples of this; see wp-includes/class-wp-customize-control.php and wp-admin/js/customize-controls.js.

WP_Customize_Cropped_Image_Control

New in WordPress 4.3, WP_Customize_Cropped_Image_Control extracts functionality from the headerHeader The header of your site is typically the first thing people will experience. The masthead or header art located across the top of your page is part of the look and feel of your website. It can influence a visitor’s opinion about your content and you/ your organization’s brand. It may also look different on different screen sizes. image control to allow an image to be cropped to specific dimensions (see #29211). This offers a better user experience than automatic cropping in many cases when images of a certain size or aspect ratio are required in themes and plugins. In core, the new site icon feature relies heavily on the cropped-image control, implementing a child custom control to add additional site-icon-specific functionality.

The cropped image control comes with four custom parameters in addition to those available in the media control. These are used to specify the required (or recommended) image dimensions, as well as specifying whether alternative dimensions are allowed (the flex options). Here’s a typical usage when adding a cropped-image control:

$wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'cropped_image', array(
	'section'     => 'background_image',
	'label'       => __( 'Croppable Image' ),
	'flex_width'  => true, // Allow any width, making the specified value recommended. False by default.
	'flex_height' => false, // Require the resulting image to be exactly as tall as the height attribute (default).
	'width'       => 1920,
	'height'      => 1080,
) ) );

The cropped-image control creates a child attachment of the original image attachment object for the cropped image, preserving the original version. The cropped-image attachment is given a context based on the control id (with _ replaced by -). The core control doesn’t currently use this, but it could be leveraged to query for previously-cropped images for a specific control to add a library feature in the future or in child controls. Be mindful that a version of the control id is stored in the database for cropped image attachments.

As with the media control, the cropped-image control saves the attachment id instead of the image URL. This can be useful for querying specific sizes of the image, but you’ll typically want the full size image at the cropped dimension. wp_get_attachment_image_src( absint( get_option( 'cropped_image_setting' ) ) ) should do the trick if that’s the case, when outputting the value of the setting.

#4-2, #4-3, #customize, #dev-notes, #media, #media-modal

Remember the Media Grid project It was original…

Remember the Media Grid project? It was original proposed back in the 3.7/3.8 cycle but never really took off — mainly due to our focus on The-Project-Formerly-Known-As-MP6 and the WidgetWidget A WordPress Widget is a small block that performs a specific function. You can add these widgets in sidebars also known as widget-ready areas on your web page. WordPress widgets were originally created to provide a simple and easy-to-use way of giving design and structure control of the WordPress theme to the user. team.

Since then, I’ve been working on a plugin in some spare time: https://wordpress.org/plugins/media-grid/

Its messy. Its basic. But I think there’s potential in the idea to bring the media modal’s layout to the Media Library. @helen created a GitHub repo for development: https://github.com/helenhousandi/wp-media-grid-view (Make sure you checkout the issues, especially: https://github.com/helenhousandi/wp-media-grid-view/issues/7)

I’m looking to form a team to work on this project. I think we could have something ready for 4.0, but 4.1 is a possibility as well. It all depends on you. 🙂

I’m looking for any-and-all help, but specifically 1-2 backbone-capable developers with familiarity with the Media Modal would be a huge help.

Maybe we can chat about this a bit during tomorrow’s Dev Chat. Outside of that, lets plan on meeting in #wordpress-ui this Friday, Apr 25 @ 16:00 UTC.

So, are you interested? Leave a comment below and/or join us on Friday. Thanks!

#media-library, #media-modal, #media-grid