Drupal 8 - images with image style

Drupal 7

image_style_url('style', uri);

Drupal 8

You need to include the namespace ImageStyle

use Drupal\image\Entity\ImageStyle;

And this is the php code you need now:

$path = db_select('file_managed','f')->fields('f',array('filename'))->condition('f.fid',$field->getValue())->execute()->fetchField();
$url = ImageStyle::load('medium')->buildUrl($path);