Skip to content

Commit

Permalink
Allow previewing changes to the post featured image
Browse files Browse the repository at this point in the history
Match the Classic Editor's behaviour by appending _thumbnail_id to the
post preview URL so that changes to the featured image are visible.
  • Loading branch information
noisysocks committed Oct 31, 2018
1 parent 3600c88 commit 0fcff22
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/editor/src/components/post-preview-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { __, _x } from '@wordpress/i18n';
import { withSelect, withDispatch } from '@wordpress/data';
import { DotTip } from '@wordpress/nux';
import { ifCondition, compose } from '@wordpress/compose';
import { addQueryArgs } from '@wordpress/url';

export class PostPreviewButton extends Component {
constructor() {
Expand Down Expand Up @@ -190,11 +191,18 @@ export default compose( [
const {
getPostType,
} = select( 'core' );

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

const postType = getPostType( getEditedPostAttribute( 'type' ) );
return {
postId: getCurrentPostId(),
currentPostLink: getCurrentPostAttribute( 'link' ),
previewLink: getAutosaveAttribute( 'preview_link' ),
previewLink,
isDirty: isEditedPostDirty(),
isNew: isEditedPostNew(),
isSaveable: isEditedPostSaveable(),
Expand Down

0 comments on commit 0fcff22

Please sign in to comment.