Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Created April 6, 2017 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raftaar1191/245d5143c10dc4b28c27db5c77976a00 to your computer and use it in GitHub Desktop.
Save raftaar1191/245d5143c10dc4b28c27db5c77976a00 to your computer and use it in GitHub Desktop.
Print the size of the element once media is open in popup
<?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