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 authored and gziolo committed Nov 20, 2018
1 parent f33498b commit 5901512
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';

function writeInterstitialMessage( targetDocument ) {
let markup = renderToString(
Expand Down Expand Up @@ -203,11 +204,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,
isSaveable: isEditedPostSaveable(),
isAutosaveable: isEditedPostAutosaveable(),
isViewable: get( postType, [ 'viewable' ], false ),
Expand Down

0 comments on commit 5901512

Please sign in to comment.