New Core Gallery Widget Targeted for WordPress 4.9

The Core Media Widgets feature plugin introduced a gallery widget in the 0.2.0 release this week. WordPress 4.8 added the new audio, image, and video widgets from this feature plugin. The gallery widget is targeted for merge into the upcoming WordPress 4.9 release.

In testing the new feature I found it to be a simple, straightforward implementation of a gallery widget that could easily replace many plugins that are currently filling this need for users. The option to edit or replace a gallery is immediately available and users can easily rearrange or randomize the images included.

On the frontend the gallery displays neatly in a thumbnail grid. I was able to change the number of columns while editing the gallery, but the preview in the admin did not match the the way the gallery looks on the frontend. The number of columns is correct on the frontend but not in the admin preview. This might cause some confusion for users if it isn’t fixed before landing in core. Contributors to the plugin are looking at this issue.

Overall, the implementation is user-friendly and similar to adding galleries in posts and pages. However, the widget could still use some testing, especially with different plugins installed. For example, with Jetpack enabled, users can choose between a thumbnail and a slideshow gallery, but the slideshow option doesn’t seem to work correctly in the widget. has several hundred plugins that implement some sort of gallery widget and these plugin authors will want to test the new core widget.

Theme authors will also need to test how the core gallery widget interacts with their themes. After testing the gallery widget with several popular themes, I found that many display the thumbnails with unsightly outlines and unpredictable spacing between images.

Weston Ruter, who authored the dev note post when the previous media widgets were introduced in 4.8, said that the paragraph regarding default theme updates is still applicable:

Themes that add custom styles to the MediaElement.js player (namely Twenty Thirteen and Twenty Fourteen) were updated from just styling it within syndicated content, to also include instances within widgets. Most themes don’t restrict styles for captioned images or media players to just post content, that is, limit CSS selectors to classes output by post_class(). If your theme does, make sure to either remove that constraint or include a .widget selector.

Ruter said another dev note will be coming with common theme changes that are required to add the right styling for galleries. Users and theme/plugin developers can test the gallery widget right now on 4.8.2 or 4.9-alpha using the Core Media Widgets plugin. Once the widget is added to WordPress, it will be deactivated in the feature plugin for future releases. Contributors plan to merge the new widget into core next week, provided testing goes well.

Would you like to write for WP Tavern? We are always accepting guest posts from the community and are looking for new contributors. Get in touch with us and let's discuss your ideas.


  1. One Question: Why are they introducing new widgets when widgets and shortcodes are to be deprecated in favor of blocks?


    1. Widgets aren’t being deprecated yet. In any case, when widgets do transition over to blocks, there is a gallery block in Gutenberg for the gallery widget to transition to. In the same way, a Custom HTML widget was introduced in 4.8.1 and there is a Custom HTML block in Gutenberg. When widgets do transition over to using blocks, users shouldn’t actually perceive any fundamental change in this regard: they’ll continue being able to use images, video, audio, galleries, custom HTML and other widgets in their sidebars as well as being able to use such widgets (blocks) for the first time in the content of their posts as well.


  2. There are two important aspects that should be addressed and, of course, implemented within gallery widget while in slideshow/lightbox mode:
    Deeplink to each image and set the necessary Open Graph Protocol’s tags in order to ensure that the image that appears on the shared post will be the same the user wanted to share inside the slideshow.


  3. Firstly this is plugin territory and should never go into core

    Secondly why bother? A more important task is to transition widget storage into the posts table as a cpt, rather than polluting the options table.


    1. I disagree. A user can add a gallery to their post content, so why shouldn’t they be able to add a gallery to their sidebars?

      Storing widgets in a custom post type is planned, see:

      However, this would probably be part of the migration from widgets to blocks. Work is being done in Gutenberg on such a block post type right now.


      1. With a do_shortcodes filter on your widget content you can include. Gallery’s right now. A specific widget is not required


  4. More great work from the Customization team. I think it’s really great how they’ve taken a user-first approach to improvements this year. Just because Gutenberg is on the horizon doesn’t mean we shouldn’t take the opportunity to make existing and new user’s lives easier today.


  5. I think this is a good improvement for widgets. Users now can insert single image, single video and now a gallery. It’s kind of a common need for users when many themes show Instagram widget in the sidebar.


Comments are closed.