Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable previewing changes to the post featured image #12037

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Nov 18, 2018

Fixes partially #9151

Match the Classic Editor's behaviour by appending _thumbnail_id to the
post preview URL so that changes to the featured image are visible.

Description

Pass the featured image id to the preview screen. Currently only works with published posts (possibly resolved by #11409)

How has this been tested?

  • Publish a post.
  • change the featured image.
  • without saving the post, click preview - the preview will show the newly selected featured image.

Screenshots

Types of changes

  • Add the featured image id as a query var when opening the preview pane

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@adamsilverstein adamsilverstein changed the title Allow previewing changes to the post featured image Enable previewing changes to the post featured image Nov 18, 2018
@adamsilverstein
Copy link
Member Author

Note: I reviewed the current core/classic editor behavior for previewing drafts and confirmed that for drafts core performs a full (draft) save for previews. whatever you set as featured image gets saved when you click preview on drafts. We should probably replicate that behavior in Gutenberg.

We can probably switch to performing a full save right in post-preview-button, then adjust the preview url handling to accommodate. Another option would be to abstract out saveForPreview action that handled saving according to the post status.

@aduth or @youknowriad appreciate any feedback on the best approach, I will open an issue to track this task separately.

let previewLink = getAutosaveAttribute( 'preview_link' );
const featuredImageId = getEditedPostAttribute( 'featured_media' );
if ( previewLink && featuredImageId ) {
previewLink = addQueryArgs( previewLink, { _thumbnail_id: featuredImageId } );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is how Core does it, I'm totally fine with the approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain though how #11409 would fix for non published posts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that you can't see the featured image until your draft is saved.

@adamsilverstein adamsilverstein mentioned this pull request Nov 19, 2018
4 tasks
@mtias mtias added [Feature] Document Settings Document settings experience [Feature] Saving Related to saving functionality labels Nov 19, 2018
@mtias mtias added this to the 4.5 milestone Nov 19, 2018
@mtias mtias added the [Feature] Media Anything that impacts the experience of managing media label Nov 19, 2018
Match the Classic Editor's behaviour by appending _thumbnail_id to the
post preview URL so that changes to the featured image are visible.
@gziolo gziolo force-pushed the try/feature-image-preview branch from 0fcff22 to 5901512 Compare November 20, 2018 10:03
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It solves the issue for drafts and published posts that are saved.
Let's ship it as is and tackle the last case separately ad @adamsilverstein suggested.

@gziolo gziolo merged commit 2fc6cae into master Nov 20, 2018
@gziolo gziolo deleted the try/feature-image-preview branch November 20, 2018 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Document Settings Document settings experience [Feature] Media Anything that impacts the experience of managing media [Feature] Saving Related to saving functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants