Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
I am sure there is a special place in hell for doing what I just did, but it work for what was needed. Pushing code manually with javascript into the wp media template...
add_action('print_media_templates', function() {
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>' +
el.outerHTML = [el.outerHTML.slice(0, pos), text, el.outerHTML.slice(pos)].join('');
}, 42);

This comment has been minimized.

Copy link

Lewiscowles1986 commented Apr 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.