I'm trying to use the get_image_tag()
function to alter the html output of an image, like so :
add_filter('get_image_tag', 'kh_image_attachment', 10, 5);
function kh_image_attachment($html, $id, $alt, $title, $align) {
$html = '<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="' . esc_attr($img_src) . '" id="'.esc_attr($id).'" alt="' . esc_attr($alt) . '" title="'.esc_attr($title).'" class="'.$class.'" onload=lzld(this) onerror=lzld(this) />';
return $html;
}
Unfortunately, the src
attribute remains empty (the class attribute as well, but I couldn't care less about that). I can't for the life of me figure out why. Can you help me out here?
Thank you.
onload
andonerror
en.wikipedia.org/wiki/Unobtrusive_JavaScript, stackoverflow.com/questions/1931925/… – janw Jul 13 '12 at 12:05