Still relevant method of embedding images in WP Theme in 2018

someone questioned me today that I am not doing it correctly?

<?php echo get_bloginfo('template_url') ?>/images/logo.png

There are 2 possible reasons this could be considered ‘incorrect’:

  • get_bloginfo is a very old function that does multiple things, this particular function was replaced by get_template_directory_uri and get_stylesheet_directory_uri
  • Security! You didn’t escape anything! The entire thing should be wrapped in an esc_url