no output on wp_get_attachment_image()
-
Hey great Plugin!
If I used the function wp_get_attachment_image() (because I use ACF Image) no output of your plugin will get.
How do I get the correct output with wp_get_attachment_image() or with another wp function?I have a little workaround for this Problem without noscript. On Template I using this:
echo wp_get_attachment_image( $imageID, $imagesize, false, array("class" => "lazyload", "alt" => $imagecontent) );
And in my functions.php
/** * Replace src with data-srcset for wp_get_attachment_image() */ function attachment_image_replace_srcset($attr) { /** * Add data-sizes and data-srcset attribute. */ $attr['data-srcset'] = $attr['srcset']; $attr['data-sizes'] = $attr['sizes']; /** * Remove sizes and srcset attribute. */ unset( $attr['srcset'] ); unset( $attr['sizes'] ); return $attr; } add_filter( 'wp_get_attachment_image_attributes', 'attachment_image_replace_srcset');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘no output on wp_get_attachment_image()’ is closed to new replies.