Skip to content

Instantly share code, notes, and snippets.

@SebCorbin
Created April 9, 2013 09:06
Show Gist options
  • Save SebCorbin/5344223 to your computer and use it in GitHub Desktop.
Save SebCorbin/5344223 to your computer and use it in GitHub Desktop.
Drupal: quickly generate an image file
<?php
$response = drupal_http_request('http://placekitten.com/g/' . $width . '/' . $height);
if ($response->code !== 200) {
// If cats are sleeping, take another image generator
$response = drupal_http_request('http://lorempixel.com/g/' . $width . '/' . $height);
}
$destination = 'public://miaou' . $width . 'x' . $height . '.png';
$file = file_save_data($response->data, $destination, FILE_EXISTS_REPLACE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment