Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Gets an attachement image as lazy loaded img based on ID
- * @param string $size Thumbnail, medium, large, original, or {custom size}
- * @param string $class CSS class name for the img tag
- * @param integer $attachment_id ID of the attachment
- * @param string $attachment_id The custom src atrribute to use, default to data-echo
- * @return string Lazyload friendly HTML img tag
- */
- function get_attachemt_lazy($size, $class, $attachment_id = "", $src_attr = "data-echo")
- {
- $src = wp_get_attachment_url($attachment_id);
- $attr = array(
- 'class' => "attachment-$size $class",
- 'src' => 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==',
- $src_attr => $src,
- );
- $output = wp_get_attachment_image($attachment_id, $size, false, $attr);
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement