Home › Forums › Support › Add HTML atrributes to featured images on all posts This topic has 3 replies, 2 voices, and was last updated 6 years, 8 months ago by Tom. Viewing 4 posts - 1 through 4 (of 4 total) Author Posts August 20, 2017 at 6:49 am #369811 David Hi team, I’d like to add the attribute data-no-lazy=”1″ to all featured images on my blog posts. What is the best way to do that with GeneratePress? Thanks David August 20, 2017 at 11:03 am #369937 TomLead Developer Lead Developer Hi David, Give this a try: add_filter( 'wp_get_attachment_image_attributes', 'tu_data_attr_featured_image', 10, 2 ); function tu_data_attr_featured_image( $attr, $attachment ) { remove_filter( 'wp_get_attachment_image_attributes', 'tu_data_attr_featured_image' ); $attr['data-no-lazy'] = '1'; return $attr; } August 20, 2017 at 12:53 pm #369982 David Thanks, Tom this works great! I added this in a GP Hooks. Is there any drawback versus adding this code in functions.php? Thanks David August 20, 2017 at 3:45 pm #370038 TomLead Developer Lead Developer Hooks are primarily meant for visual elements. I would definitely use your functions.php file, or a plugin like Code Snippets. Glad it works 🙂 Author Posts Viewing 4 posts - 1 through 4 (of 4 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In