Drupal 8 images with image style

user3810914 picture user3810914 · Jul 15, 2014 · Viewed 26.3k times · Source

In drupal 7, i use function image_style_url('style', uri) to generate new image with style and return image's path. so what will be instead of it in drupal 8? thanks

Answer

Clive picture Clive · Jul 15, 2014

Per the change records:

use Drupal\image\Entity\ImageStyle;

$path = 'public://images/image.jpg';
$url = ImageStyle::load('style_name')->buildUrl($path);