Created
April 9, 2013 09:06
-
-
Save SebCorbin/5344223 to your computer and use it in GitHub Desktop.
Drupal: quickly generate an image file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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