Jul 01, 2019 in Drupal 8, Snippets

A much needed functionality is how you get the url of an image style form the uri (f.e. in a node object). This snippets helps you accomplish this.

use Drupal\image\Entity\ImageStyle;

$url = ImageStyle::load('large')->buildUrl($node->field_image->entity->getFileUri());
// You now have the url of your image