Last active
June 13, 2016 21:09
-
-
Save mkormendy/bd033c4e0ec7941e592aca31b77e5c16 to your computer and use it in GitHub Desktop.
Pushing code manually with javascript into the wp media template...
This file contains hidden or 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
| add_action('print_media_templates', function() { | |
| ?> | |
| <script> | |
| var el = document.getElementById('tmpl-attachment'); | |
| var pos = el.outerHTML.indexOf('<# } else if ( \'image\' === data.type && data.sizes ) { #>'); | |
| var text = '<# } else if ( \'svg+xml\' === data.subtype ) { #>\n' + | |
| '<div class="centered">\n' + | |
| '<img src="{{ data.url }}" class="thumbnail" draggable="false" />\n' + | |
| '</div>\n' + | |
| '<div class="filename">' + | |
| '<div>{{ data.filename }}</div>' + | |
| '</div>'; | |
| el.outerHTML = [el.outerHTML.slice(0, pos), text, el.outerHTML.slice(pos)].join(''); | |
| </script> | |
| <?php | |
| }, 42); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment