Skip to content

Instantly share code, notes, and snippets.

@zeropaper
Created March 19, 2018 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeropaper/bc5d48b112ebe62caed57364226be6c9 to your computer and use it in GitHub Desktop.
Save zeropaper/bc5d48b112ebe62caed57364226be6c9 to your computer and use it in GitHub Desktop.
Drupal 8 generate style derivative image
// can be runned from the Devel execute PHP page
use Drupal\image\Entity\ImageStyle;
$path = 'public://2018-03/26756519_10155441271337695_6783993404862700965_o.jpg';
$thumbnail = ImageStyle::load('article');
dpm($thumbnail->buildUrl($path));
$dest = $thumbnail->buildUri($path);
dpm($dest);
$created = $thumbnail->createDerivative($path, $dest);
dpm('created? ' . $created);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment