Created
March 19, 2022 08:19
-
-
Save marcusig/8934e1afea6420b8d63ce0eb033a8de3 to your computer and use it in GitHub Desktop.
Wrap layer images with a div. One div per layer
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.viewer.item.added', 'MKL/PC/Custom_JS', function( view, viewer ) { | |
// Set the class name | |
var layer_class = 'layer-' + view.model.get( 'layerId' ); | |
// Find the existing container. | |
var layer_container = viewer.$layers.find( '.' + layer_class ); | |
if ( ! layer_container.length ) { | |
// If the container doesn't exist, add it | |
view.$el.wrap( '<div class="' + layer_class + '" />' ); | |
} else { | |
layer_container.append( view.$el ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment