function Attribute::ImageSave in Realistic Dummy Content 8
Return an image file object if possible.
Parameters
$file: The FileGroup object
Return value
NULL if the file is not an image, or if an error occurred; otherwise a Drupal file object.
2 calls to Attribute::ImageSave()
- ImageField::ValueFromFile_ in api/
src/ attributes/ ImageField.php - Given a FileGroup object, get a structured property
- UserPicture::ValueFromFile_ in api/
src/ attributes/ UserPicture.php - Given a FileGroup object, get a structured property
File
- api/
src/ attributes/ Attribute.php, line 300 - Define autoload class.
Class
- Attribute
- Represents either a field or a property for an entity.
Namespace
Drupal\realistic_dummy_content_api\attributesCode
function ImageSave($file) {
try {
$exists = $file
->Value();
if (!$exists) {
throw new Exception('Please check if the file exists before attempting to save it');
}
$return = NULL;
if (in_array($file
->GetRadicalExtension(), $this
->GetImageExtensions())) {
$return = $this
->FileSave($file);
$alt = $file
->Attribute('alt');
if ($alt) {
$return->alt = $alt;
}
}
return $return;
} catch (\Exception $e) {
return NULL;
}
}