public function AFile::getImage in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2
Gets as image object.
1 call to AFile::getImage()
- FileCommited::resizeImage in src/
Flmngr/ FileUploaderServer/ lib/ file/ FileCommited.php - Resizes an image.
File
- src/
Flmngr/ FileUploaderServer/ lib/ file/ AFile.php, line 240
Class
- AFile
- Abstract file item both for just uploaded and fully commited files. Contains some handy method for accessing files info programmatically.
Namespace
Drupal\n1ed\Flmngr\FileUploaderServer\lib\fileCode
public function getImage() {
$path = $this
->getFullPath();
$image = NULL;
switch (strtolower($this
->getExt())) {
case 'gif':
$image = @imagecreatefromgif($path);
break;
case 'jpeg':
case 'jpg':
$image = @imagecreatefromjpeg($path);
break;
case 'png':
$image = @imagecreatefrompng($path);
break;
case 'bmp':
$image = @imagecreatefromwbmp($path);
break;
}
// Somewhy it can not read ONLY SOME JPEG files,
// we've caught it on Windows + IIS + PHP
// Solution from here: https://github.com/libgd/libgd/issues/206
if (!$image) {
$image = imagecreatefromstring(file_get_contents($path));
}
if (!$image) {
throw new MessageException(Message::createMessage(Message::IMAGE_PROCESS_ERROR));
}
imagesavealpha($image, TRUE);
return $image;
}