conditionally load a default static image if image metabox has no value

According to the get_post_meta() function reference in the WordPress Codex, “If there is nothing to return the function will return an empty array unless $single has been set to true, in which case an empty string is returned.”

That means we can use ternary operators to check whether get_post_meta() returns an empty string, and if so then we assign the static image instead. We’ll only need to modify the line where the $img variable is defined:

$img = 
  ( '' == get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )
  ?
  get_template_directory_uri() . '/images/default-img.png' // updated example per comment
  :
  wp_get_attachment_image( get_post_meta( get_the_ID(), '_articles_image_id', 1 ), 'full', 1, get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )
  ;