Skip to content

Instantly share code, notes, and snippets.

@marcusig
Created October 20, 2021 05:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusig/d48cc4c73245cf8b855e30f48b489140 to your computer and use it in GitHub Desktop.
Save marcusig/d48cc4c73245cf8b855e30f48b489140 to your computer and use it in GitHub Desktop.
Show the current choice's thumbnail in the layer's header
wp.hooks.addAction( 'PC.fe.layers_list_item.init', 'Antonio.selected.image', function( view ) {
var content = PC.fe.getLayerContent( view.model.id );
view.listenTo( content, 'change:active', function( choice_model, activated ) {
if ( activated ) {
var image = choice_model.get_image( 'thumbnail' );
if ( image ) {
view.$( '.layer-item .img' ).html( '<img src="' + image + '">' );
}
}
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment