public function FppTestHelper::generateImageFile in Fieldable Panels Panes (FPP) 7
Create an image file object of a specific size & type.
Parameters
string $image_size: The size of the requested image in 'XxY' format; defaults to '200x200'.
string $format: The image format to use, defaults to 'png'.
string $scheme: The file storage scheme, should be either 'private' or 'public'; defaults to 'public'.
Return value
object The file object for the generated image.
1 call to FppTestHelper::generateImageFile()
- FppFileAccessTest::createTestFppObject in tests/
fpp.file_access.test - Create a test FPP object that contains a generated image.
File
- tests/
fpp.helper.test, line 117 - A base class for the Fieldable Panels Panes tests, provides shared methods.
Class
- FppTestHelper
- A base class for the Fieldable Panels Panes tests, provides shared methods.
Code
public function generateImageFile($image_size = '200x200', $format = 'png', $scheme = 'public') {
// Generate a test image.
$image_uri = $this
->generateImage($image_size, $format, $scheme);
// Create a file object for this image.
$file = new StdClass();
$file->fid = NULL;
$file->uid = 1;
$file->uri = $image_uri;
$file->filemime = file_get_mimetype($image_uri);
$file->filesize = filesize($image_uri);
$file->status = 1;
$file->timestamp = filemtime($image_uri);
$saved_file = file_save($file);
return $saved_file;
}