|
32 | 32 | use xPDO\Cache\xPDOCacheManager; |
33 | 33 | use xPDO\Om\xPDOCriteria; |
34 | 34 | use xPDO\xPDO; |
| 35 | +use MODX\Revolution\modPhpThumb; |
35 | 36 |
|
36 | 37 | /** |
37 | 38 | * An abstract base class extend to implement loading your League\Flysystem\AbstractAdapter |
@@ -1182,7 +1183,27 @@ public function uploadObjectsToContainer($container, array $objects = []) |
1182 | 1183 | } |
1183 | 1184 |
|
1184 | 1185 | try { |
1185 | | - $this->filesystem->write($newPath, file_get_contents($file['tmp_name'])); |
| 1186 | + $image_extensions = ['jpg', 'jpeg']; |
| 1187 | + $file_extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); |
| 1188 | + |
| 1189 | + if (in_array($file_extension, $image_extensions)) { |
| 1190 | + $exif = @exif_read_data($file['tmp_name']); |
| 1191 | + if (!empty($exif['Orientation']) && $exif['Orientation'] > 1) { |
| 1192 | + $phpThumb = new modPhpThumb($this->xpdo, []); |
| 1193 | + $phpThumb->setSourceFilename($file['tmp_name']); |
| 1194 | + $phpThumb->setParameter('ar', 'x'); |
| 1195 | + if ($phpThumb->GenerateThumbnail()) { |
| 1196 | + $image_string = $phpThumb->OutputThumbnailData(); |
| 1197 | + $this->filesystem->write($newPath, $image_string); |
| 1198 | + } else { |
| 1199 | + $this->filesystem->write($newPath, file_get_contents($file['tmp_name'])); |
| 1200 | + } |
| 1201 | + } else { |
| 1202 | + $this->filesystem->write($newPath, file_get_contents($file['tmp_name'])); |
| 1203 | + } |
| 1204 | + } else { |
| 1205 | + $this->filesystem->write($newPath, file_get_contents($file['tmp_name'])); |
| 1206 | + } |
1186 | 1207 | } catch (FilesystemException | UnableToWriteFile $e) { |
1187 | 1208 | $this->addError('path', $this->xpdo->lexicon('file_err_upload')); |
1188 | 1209 | $this->xpdo->log(modX::LOG_LEVEL_ERROR, $e->getMessage()); |
|
0 commit comments