Skip to content

Instantly share code, notes, and snippets.

@init90
Last active May 5, 2018 21:41
Show Gist options
  • Save init90/51df1d82fc5d4b4746ee23de247ca5b7 to your computer and use it in GitHub Desktop.
Save init90/51df1d82fc5d4b4746ee23de247ca5b7 to your computer and use it in GitHub Desktop.
Drupal 8 load image and display itwith preset.
use Drupal\image\Entity\ImageStyle;
$file = \Drupal\file\Entity\File::load(17);
$uri = $file->getFileUri();
$url = ImageStyle::load('small_user_pic')->buildUrl($uri);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment