Skip to content

Commit

Permalink
Merge pull request #1334 from WordPress/fix/embed-photos
Browse files Browse the repository at this point in the history
Add html generation for photo type embed previews
  • Loading branch information
notnownikki committed Jun 22, 2017
2 parents 3c05428 + 503e780 commit 541d6b9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions blocks/library/embed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ function getEmbedBlockSettings( { title, icon, category = 'embed' } ) {
this.unmounting = true;
}

getPhotoHtml( photo ) {
const photoPreview = <p><img src={ photo.thumbnail_url } alt={ photo.title } /></p>;
return wp.element.renderToString( photoPreview );
}

doServerSideRender( event ) {
if ( event ) {
event.preventDefault();
Expand All @@ -90,6 +95,8 @@ function getEmbedBlockSettings( { title, icon, category = 'embed' } ) {
const { html, type } = obj;
if ( html ) {
this.setState( { html, type } );
} else if ( 'photo' === type ) {
this.setState( { html: this.getPhotoHtml( obj ), type } );
} else {
this.setState( { error: true } );
}
Expand Down

0 comments on commit 541d6b9

Please sign in to comment.