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

Projects
None yet
5 participants
@adamsilverstein
Contributor

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 from Allow previewing changes to the post featured image to Enable previewing changes to the post featured image Nov 18, 2018

@adamsilverstein

This comment has been minimized.

Contributor

adamsilverstein commented Nov 19, 2018

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 } );

This comment has been minimized.

@youknowriad

youknowriad Nov 19, 2018

Contributor

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

This comment has been minimized.

@youknowriad

youknowriad Nov 19, 2018

Contributor

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

This comment has been minimized.

@gziolo

gziolo Nov 20, 2018

Member

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

@adamsilverstein adamsilverstein referenced this pull request Nov 19, 2018

Merged

Save meta on preview #11409

4 of 4 tasks complete

@mtias mtias added this to the 4.5 milestone Nov 19, 2018

@mtias mtias added the Media label Nov 19, 2018

Allow previewing changes to the post featured image
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 Nov 20, 2018

@gziolo

gziolo approved these changes Nov 20, 2018

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@gziolo gziolo deleted the try/feature-image-preview branch Nov 20, 2018

grey-rsi pushed a commit to OnTheGoSystems/gutenberg that referenced this pull request Nov 22, 2018

Allow previewing changes to the post featured image (WordPress#12037)
Match the Classic Editor's behaviour by appending _thumbnail_id to the
post preview URL so that changes to the featured image are visible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment