Created
April 6, 2017 06:19
-
-
Save raftaar1191/245d5143c10dc4b28c27db5c77976a00 to your computer and use it in GitHub Desktop.
Print the size of the element once media is open in popup
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
<?php | |
/** | |
* Add script in the footer that will display size of the media when popup is opened. | |
*/ | |
function tmp_rtm_wp_footer_display_size_of_lightbox() { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
// Fire when media is open in popup. | |
rtMediaHook.register( 'rtmedia_js_popup_after_content_added', function() { | |
// Fire after 0.5 second. | |
setTimeout(function(){ | |
// Display height of the element 'rtmedia-media'. | |
console.log( jQuery('.rtmedia-media').height() ); | |
// Display width of the element 'rtmedia-media'. | |
console.log( jQuery('.rtmedia-media').width() ); | |
}, 500); | |
return true; | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'tmp_rtm_wp_footer_display_size_of_lightbox', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment