Last active
October 14, 2016 08:11
-
-
Save joemcgill/7965462 to your computer and use it in GitHub Desktop.
A poor man's var_dump for the image_send_to_editor() filter in Wordpress. Throw this in your functions.php file and add an image to your post to see what get's passed. Filter it however you want to return the image however you want.
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
<?php | |
function show_img_vars($html, $id, $caption, $title, $align, $url, $size, $alt) { | |
// round up all the variables that get passed so we can test them | |
$vars = "html = $html\n"; | |
$vars .= "id = $id\n"; | |
$vars .= "caption = $caption\n"; | |
$vars .= "title = $title\n"; // this will end up blank no matter what | |
$vars .= "align = $align\n"; | |
$vars .= "url = $url\n"; | |
$vars .= "size = $size\n"; | |
$vars .= "alt = $alt\n"; | |
// return the normal html output you would expect | |
$return = $html . "\n"; | |
// add our ad-hoc var dump to the editor | |
$return .= "<!-- args \n"; | |
$return .= $vars; | |
$return .= "/args -->"; | |
return $return; | |
} | |
add_filter( 'image_send_to_editor', 'show_img_vars', 10, 9 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment