public static function download_lorem_image()
    {
        $url = 'http://lorempixel.com/1024/768?t='.uniqid();
        $img_filename = "mock-file-".uniqid().".jpeg";

        $img = self::get_mock_folder()->getFullPath().$img_filename;

        if (ini_get('allow_url_fopen')) {
            file_put_contents($img, file_get_contents($url));
        } else {
            $ch = curl_init($url);
            $fp = fopen($img, 'wb');
            curl_setopt($ch, CURLOPT_FILE, $fp);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_exec($ch);
            curl_close($ch);
            fclose($fp);
        }

        if (!file_exists($img) || !filesize($img)) {
            return false;
        }

        $i = Image::create();
        $i->Filename = self::get_mock_folder()->Filename.$img_filename;
        $i->Title = $img_filename;
        $i->Name = $img_filename;
        $i->ParentID = self::get_mock_folder()->ID;
        $i->write();

        return $i;
    }
public static function download_lorem_image()
    {
        $url = 'http://lorempixel.com/1024/768?t='.uniqid();
        $img_filename = "mock-file-".uniqid().".jpeg";

        $img = self::get_mock_folder()->getFullPath().$img_filename;

        if (ini_get('allow_url_fopen')) {
            file_put_contents($img, file_get_contents($url));
        } else {
            $ch = curl_init($url);
            $fp = fopen($img, 'wb');
            curl_setopt($ch, CURLOPT_FILE, $fp);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_exec($ch);
            curl_close($ch);
            fclose($fp);
        }

        if (!file_exists($img) || !filesize($img)) {
            return false;
        }

        $i = Image::create();
        $i->Filename = self::get_mock_folder()->Filename.$img_filename;
        $i->Title = $img_filename;
        $i->Name = $img_filename;
        $i->ParentID = self::get_mock_folder()->ID;
        $i->write();

        return $i;
    }
public static function download_lorem_image ( ) { $ url = 'http://lorempixel.com/1024/768?t=' . uniqid ( ) ; $ img_filename = "mock-file-" . uniqid ( ) . ".jpeg" ; $ img = self :: get_mock_folder ( ) -> getFullPath ( ) . $ img_filename ; if ( ini_get ( 'allow_url_fopen' ) ) { file_put_contents ( $ img , file_get_contents ( $ url ) ) ; } else { $ ch = curl_init ( $ url ) ; $ fp = fopen ( $ img , 'wb' ) ; curl_setopt ( $ ch , CURLOPT_FILE , $ fp ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_exec ( $ ch ) ; curl_close ( $ ch ) ; fclose ( $ fp ) ; } if ( ! file_exists ( $ img ) || ! filesize ( $ img ) ) { return false ; } $ i = Image :: create ( ) ; $ i -> Filename = self :: get_mock_folder ( ) -> Filename . $ img_filename ; $ i -> Title = $ img_filename ; $ i -> Name = $ img_filename ; $ i -> ParentID = self :: get_mock_folder ( ) -> ID ; $ i -> write ( ) ; return $ i ; }
Downloads a random image from a public website and installs it into the filesystem

@todo This should really be an injectable service. It locks the user into a specific URL.
@return Image
Downloads a random image from a public website and installs it into the filesystem