How to display default image in Drupal 8
Instead of doing this in code, the Drupal core image fields provide a default image setting in the UI as well. 

If you navigate to an image field in the UI (Structure > Content types > [Add/Edit a content type] > Manage fields > [Add/Edit image field]), you can upload a default picture that will be used by Drupal in case no image was provided.