Skip to content

Commit

Permalink
Bug fix for uploaded images with corrupt header
Browse files Browse the repository at this point in the history
  • Loading branch information
tiloschroeder committed Jun 30, 2019
1 parent 3843d1e commit 559df6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ __Note__: This extension requires a little hack (use at your own risk).

## The hack: Add a delegate

To work this extension, it needs a delegate in the upload function of Symphony ([What is a delegate?](https://www.getsymphony.com/learn/concepts/view/delegates/)).
To get this extension to work, it needs a delegate in the upload function of Symphony ([What is a delegate?](https://www.getsymphony.com/learn/concepts/view/delegates/)).

1. Go to the folder ```symphony/lib/toolkit``` and open the file ```class.general.php```.
2. After ```line 1468``` insert the following line:
Expand Down
17 changes: 11 additions & 6 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ public function manipulateTmpFile($context)
{
if (extension_loaded('gd') && function_exists('gd_info')) {
$tmp_file = $context['tmp'];

$mimetype = GENERAL::getMimeType($tmp_file);

if ($mimetype === 'image/jpeg') {

$exif = exif_read_data( $tmp_file );

if (isset($exif) && isset($exif['Orientation'])) {

$this->rotateImage($tmp_file, $exif['Orientation']);
try {
$exif = exif_read_data( $tmp_file );
if (isset($exif) && isset($exif['Orientation'])) {
$this->rotateImage($tmp_file, $exif['Orientation']);
}
}
catch (Exception $ex) {
if (Symphony::Log()) {
Symphony::Log()->pushExceptionToLog($ex, true);
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
</author>
</authors>
<releases>
<release version="1.0.0" date="2019-01-26" min="2.7.0" max="2.7.x">
<release version="1.0.2" date="2019-07-01" min="2.7.0" max="2.7.x">
- Bug fix for uploaded images with corrupt header
</release>
<release version="1.0.1" date="2019-04-08" min="2.7.0" max="2.7.x">
- Edit readme
</release>
<release version="1.0.0" date="2019-04-07" min="2.7.0" max="2.7.x">
- Initial release
</release>
</releases>
Expand Down

0 comments on commit 559df6b

Please sign in to comment.