Created
October 20, 2021 05:23
-
-
Save marcusig/d48cc4c73245cf8b855e30f48b489140 to your computer and use it in GitHub Desktop.
Show the current choice's thumbnail in the layer's header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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