Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 8 years ago

#21776 closed task (blessed) (fixed)

Integrate featured images with new media workflow

Reported by: koopersmith's profile koopersmith Owned by: koopersmith's profile koopersmith
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: has-patch needs-testing
Focuses: Cc:

Description

Fairly self-explanatory. I'd like featured images to be one of the first workflows integrated, as it is one of the simplest.

Attached is a patch that mirrors the current workflow (but does not remove/alter the code). It is certainly not perfect; I'd like to build up some methods to make a few of these tasks simpler. Moving forward, I also plan on adding a dropzone directly to the featured image metabox. This may turn out to be a common pattern (as we use a similar UI in the customizer), in which case we should consider abstracting it.

Attachments (10)

21776.diff (6.9 KB) - added by koopersmith 12 years ago.
21776.2.diff (6.0 KB) - added by koopersmith 12 years ago.
21776.non-image.png (18.7 KB) - added by SergeyBiryukov 12 years ago.
21776.3.diff (4.2 KB) - added by nacin 11 years ago.
21776.4.diff (3.6 KB) - added by nacin 11 years ago.
21776.5.diff (5.6 KB) - added by nacin 11 years ago.
21776.6.diff (18.6 KB) - added by koopersmith 11 years ago.
21776.7.diff (21.2 KB) - added by koopersmith 11 years ago.
21776.7-refresh.diff (21.2 KB) - added by DrewAPicture 11 years ago.
refresh at r22973
21776.galleries.diff (1.0 KB) - added by koopersmith 11 years ago.

Download all attachments as: .zip

Change History (60)

@koopersmith
12 years ago

#1 @ocean90
12 years ago

Related: #14762

#2 @scribu
12 years ago

  • Cc scribu added

#3 @nacin
12 years ago

I think a different Ajax endpoint is preferred due to the change in return values, but we'll probably want to keep the existing meta box, and simply replace the contents of post_thumbnail_meta_box(). This is mainly to keep consistency with a plugin that might replace or remove that box.

We might want to just do a ?return=json and keep the same endpoint.

@koopersmith
12 years ago

#4 @koopersmith
12 years ago

21776.2.diff replaces the AJAX endpoint with code in edit_post(), as the thumbnail should update when the publish/update button is clicked (rather than instantly). It does not, however merge the meta box functions.

#5 @nacin
12 years ago

Marked #17100 and #12922 as duplicates, as 21776.2.diff would no longer save the thumbnail instantly, instead requiring a save.

#6 @koopersmith
12 years ago

Marked #14762 as a duplicate, as 21776.2.diff eliminates the ambiguity between choosing a featured image and inserting an image into a post.

#7 @koopersmith
12 years ago

In [21770]:

First pass at integrating featured images with the new media workflow.

Updates the featured image when the publish/update button is clicked (rather than instantly). Uses the existing post_thumbnail_meta_box() function. Does not remove the old featured image meta box JS, ajax handler, or CSS.

see #21776, #21390.

#3 @koopersmith
12 years ago

In [21771]:

Prevent JS events from being garbage collected when a media.view.Modal is re-rendered. see #21390, #21776.

#4 @SergeyBiryukov
12 years ago

Non-images should be filtered out when selecting a featured image: 21776.non-image.png.

#5 @dosboy
12 years ago

When adding a featured image with the current codebase, the lightbox appears, throws a JS error, then fails to let me do anything.

Uncaught ReferenceError: type is not defined
(anonymous function)
b.template.c load-scripts.php:423
_.extend.template load-scripts.php:466
e.view.Attachment.Backbone.View.extend.render load-scripts.php:468
e.view.Attachments.Backbone.View.extend.add load-scripts.php:468
e.view.Attachments.Backbone.View.extend.initialize.list load-scripts.php:468
g.Events.trigger load-scripts.php:435
f.extend._onModelEvent load-scripts.php:450
g.Events.trigger load-scripts.php:435
f.extend.add load-scripts.php:445
media.model.Attachments.Backbone.Collection.extend._mirrorAdd load-scripts.php:466
g.Events.trigger load-scripts.php:435
f.extend._onModelEvent load-scripts.php:450
g.Events.trigger load-scripts.php:435
f.extend.add load-scripts.php:445
f.extend.fetch.a.success load-scripts.php:449
p.Callbacks.k load-scripts.php:2
p.Callbacks.l.fireWith load-scripts.php:2
_.extend.ajax load-scripts.php:466
p.Callbacks.k load-scripts.php:2
p.Callbacks.l.fireWith load-scripts.php:2
y load-scripts.php:2
p.support.ajax.p.ajaxTransport.send.d load-scripts.php:2

#6 @dosboy
12 years ago

Ignore previous error report. It seems to be resolved as of this morning.

#7 @koopersmith
11 years ago

In [22021]:

Media JS: Add support for filtering Attachment collections by mime type. see #21390, #21776, #21809.

#18 @koopersmith
11 years ago

In [22022]:

Limit the featured image workflow to images only.

Adds the ability to set the values used to instantiate both the Workflow's library and selection.
Renames the Workflows internal _pending variable to prevent conflicts with a similarly named internal Backbone.Model variable.

see #21390, #21776.

#19 @koopersmith
11 years ago

In [22044]:

Media JS: Move the modal box's title from being stored in the modal view to being stored as an attribute on the workflow. Update modal titles for both the post media and featured image workflows. see #21390, #21776.

#21 @ocean90
11 years ago

Featured images are attached to the post in 3.4, in trunk this behavior is gone.

#22 @scribu
11 years ago

If I understood it correctly, we are de-emphasising the post_parent field for attachments, in the sense that it now only keeps a record of which post you were on when you originally uploaded the image.

#23 @nacin
11 years ago

If the featured image is uploaded against that post, then it will be attached to the post. Otherwise, it won't be. Pretty sure that's the same behavior in 3.4 too.

#24 in reply to: ↑ 20 @TomAuger
11 years ago

Replying to ocean90:

See http://wordpress.org/support/topic/post-feature-image-bug-in-wordpress-35-beta-1

I can confirm this behaviour. It should be noted that selecting an _already uploaded_ image WILL correctly update the featured image.

#25 @koopersmith
11 years ago

In [22175]:

Media Modal: Only automatically select uploading attachments when in a workflow that supports multiple images.

Fixes a bug in featured images where uploading an image would force you to reopen the modal (as the modal would close on upload).

see #21390, #21776.

#26 follow-up: @DrewAPicture
11 years ago

  • Cc xoodrew@… added

Does this ticket cover actually setting the Featured image from the modal after upload? After a post in the alpha/beta forum I realized this isn't currently possible.

#27 @koopersmith
11 years ago

In 22321:

Add a sidebar to the media modal.

  • Adds wp.media.view.Sidebar, to aid in rendering the sidebar.
  • Removes the directions from the Attachments view and shifts search into a separate view (wp.mce.view.Search) that can be relocated at will. This also serves to simplify the Attachments view by removing the nested list and $list parameters.
  • Show the toolbar on the featured image workflow, effectively requiring confirmation before closing the dialog.

see #21390, #21776, #21808.

#28 follow-up: @georgestephanis
11 years ago

Current status in trunk looks like a minor regression from a couple days ago. A couple days ago (Monday?), when clicking "Choose a Featured Image" the button was initially labeled appropriately as "Set As Featured Image" -- however in current trunk, that button is no longer available -- it starts out as "Set as Featured Image".

Also -- as of Monday's trunk, when changing from "Upload Files" to "Media Library" and back, the button changed verbiage to "Insert into Post" -- rather than "Set as Featured Image".

#29 @koopersmith
11 years ago

  • Resolution set to fixed
  • Status changed from new to closed

In 22496:

Media: Update featured images to use the media frame. fixes #21776, see #21390.

#30 in reply to: ↑ 28 @koopersmith
11 years ago

Replying to georgestephanis:

Current status in trunk looks like a minor regression from a couple days ago. A couple days ago (Monday?), when clicking "Choose a Featured Image" the button was initially labeled appropriately as "Set As Featured Image" -- however in current trunk, that button is no longer available -- it starts out as "Set as Featured Image".

Also -- as of Monday's trunk, when changing from "Upload Files" to "Media Library" and back, the button changed verbiage to "Insert into Post" -- rather than "Set as Featured Image".

Yep, featured images got a little out of sync as we shifted around the pieces. Should be all set now.

#31 in reply to: ↑ 26 @koopersmith
11 years ago

Replying to DrewAPicture:

Does this ticket cover actually setting the Featured image from the modal after upload? After a post in the alpha/beta forum I realized this isn't currently possible.


It did, in a way — the original plan for 3.5 was to omit this feature entirely. I think 3.5 has evolved to the point where a "Featured Image" tab might feel at home the "Add Media" modal (as opposed to feeling jammed in, as it previously did). That said, this is something that will have to wait until 3.6 (and should move to a new ticket).

#32 @koopersmith
11 years ago

In 22500:

Media: Make "update featured image" button primary. see #21776, #21390.

#33 @koopersmith
11 years ago

In 22561:

Media: Activate the featured image toolbar when the media dialog is first opened. see #21390, #21776.

#34 @nacin
11 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I think 3.5 has evolved to the point where a "Featured Image" tab might feel at home the "Add Media" modal (as opposed to feeling jammed in, as it previously did).

After quite a bit of feedback from the WordPress.com support forums, it seems the lack of a button here has put a severe cramp in many people's workflows. We should aim to work something in.

#35 @nacin
11 years ago

If there is anything we can do in the process to greatly simplify the JS in the post thumbnail meta box, that would be good, because plugins are inevitably going to copy it. Right now it has no semblance of being an API, unfortunately.

Related: #22636, restoring an old filter. Might be worth re-tying the rendering back into an ajax request like send-attachment-to-editor.

#36 @ryan
11 years ago

Based on wordpress.com feedback, it seems that almost no one notices the "Featured Image" metabox.

#37 @bradyvercher
11 years ago

  • Cc brady@… added

@nacin
11 years ago

@nacin
11 years ago

@nacin
11 years ago

@koopersmith
11 years ago

#38 @koopersmith
11 years ago

attachment:21776.6.diff enables the old featured images meta box, but rigs it up to a new featured image panel in the media modal.

It also:

  • Converts the modal view to use the view manager, which means that a call to open() will automatically call render and attach if necessary.
  • Doesn't automatically set a state in wp.media, to allow code to customize the states to be added before activation.

#39 @koopersmith
11 years ago

  • Keywords has-patch needs-testing added

#40 follow-up: @DrewAPicture
11 years ago

Testing 21776.6.diff:

Initially setting the featured image via both the main and featured image modals works as expected. Beyond that, there are a couple of problems.

  • If you click the 'Remove Featured Image' link via the metabox, the image disappears (as expected) but that leaves the Featured Image metabox empty, e.g. the 'Set Featured image' link isn't restored.
  • Once you've set the Featured image, clicking Add Media opens into the >Featured Image tab instead of >Upload Images
  • If the featured image is already set, you can't always change it. Sometimes the image gets replaced with the new one in the metabox, sometimes the image disappears and the 'set' link is restored, sometimes nothing happens at all.
Last edited 11 years ago by DrewAPicture (previous) (diff)

#41 @koopersmith
11 years ago

Note that this will also fix #22636.

#42 in reply to: ↑ 40 ; follow-up: @koopersmith
11 years ago

Thanks, DrewAPicture, this is all very helpful.

Replying to DrewAPicture:

  • If the featured image is already set, you can't always change it. Sometimes the image gets replaced with the new one in the metabox, sometimes the image disappears and the 'set' link is restored, sometimes nothing happens at all.

Can you elaborate on this point? Any JS errors? Can you isolate any actions that cause the featured image to always update successfully or always break?

#43 in reply to: ↑ 42 @DrewAPicture
11 years ago

Replying to koopersmith:

Replying to DrewAPicture:

  • If the featured image is already set, you can't always change it. Sometimes the image gets replaced with the new one in the metabox, sometimes the image disappears and the 'set' link is restored, sometimes nothing happens at all.

Can you elaborate on this point? Any JS errors? Can you isolate any actions that cause the featured image to always update successfully or always break?

Per my revelation in IRC, seems like replacing the featured image via Add Media works as expected, replacing via clicking the already-set featured image in the metabox doesn't work.

I also noticed that if I click the "Remove featured image" link and attempt to set a new one via Add Media, it doesn't load anything in the metabox, but that may be related to the first bullet point in comment:40.

@koopersmith
11 years ago

#44 follow-up: @koopersmith
11 years ago

This patch should fix all 3 issues.

#45 @nacin
11 years ago

#22636 was marked as a duplicate.

@DrewAPicture
11 years ago

refresh at r22973

#46 in reply to: ↑ 44 @DrewAPicture
11 years ago

Replying to koopersmith:

This patch should fix all 3 issues.

21776.7-refresh.diff fixes all three for me.

#47 @koopersmith
11 years ago

Thanks for the refresh. Looks good.

#48 @DrewAPicture
11 years ago

Noticed two issues testing 21776.7-refresh with QuickPress:

  • Once you've selected a featured image and clicked the 'Set Featured image' button, you're sent to wp-admin/index.php# which jumps you to the bottom of the page forcing you to scroll back up.
Last edited 11 years ago by DrewAPicture (previous) (diff)

#49 @nacin
11 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 22979:

Bring Featured Images back into the main media dialog.

Most users don't realize that the Featured Image meta box exists; if they do, few use it.

Restores the old meta box UI, including the admin_post_thumbnail_html filter. If a plugin is using _wp_post_thumbnail_html() in conjunction with Thickbox elsewhere, it will also magically still work.

Specific underlying changes:

  • Converts the modal view to use the view manager, which means that a call to open() will automatically call render and attach if necessary.
  • Doesn't automatically set a state in wp.media, to allow code to customize the states to be added before activation.

props koopersmith.
fixes #21776.

#50 @koopersmith
11 years ago

Patch updates gallery editing to work with the modal changes. Also adds nice handling for default states.

#52 @ryan
11 years ago

In 22984:

Update gallery editing to work with the modal changes. Add nice handling for default states.

Props koopersmith
see #21776

#53 @nacin
11 years ago

In 23058:

Admin ajax: Roll back new-style error sending in set-post-thumbnail. The JS handlers know to parse an unrecognized response (like -1 or 0) as a failure. see #21776. see #22750.

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


9 years ago

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


8 years ago

Note: See TracTickets for help on using tickets.