Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Model/Behavior/UploadBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ protected function _resizePhp(Model $model, $field, $path, $size, $geometry, $th
$outputHandler = 'imagepng';
$supportsQuality = true;
// convert 0 (lowest) - 100 (highest) thumbnailQuality, to 0 (highest) - 9 (lowest) quality (see http://php.net/manual/en/function.imagepng.php)
$adjustedQuality = intval((100 - $this->settings[$model->alias][$field]['thumbnailQuality']) / 100 * 9);
$adjustedQuality = (int)((100 - $this->settings[$model->alias][$field]['thumbnailQuality']) / 100 * 9);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is OK for Merge, intval() old function PHP4 for format correct cast val in PHP 5.

$adjustedQuality = (int)((100 - $this->settings[$model->alias][$field]['thumbnailQuality']) / 100 * 9);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: intval should work just fine in PHP 5.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
If it works well intval() in PHP 5, but is not recommended to use more it is a function deprecator. Also in the same code is being used cast (int) and for better code quality must remain consistent.

Example:
UploadBehavior.php
Lines 508, 605.630, etc ...

break;
default:
return false;
Expand Down Expand Up @@ -1508,12 +1508,12 @@ protected function _createImageResource($filename, $pathInfo) {
*/
protected function _imagecreatefromjpegexif($filename) {
$image = imagecreatefromjpeg($filename);
$exif = false;
$exif = array();
if (function_exists('exif_read_data')) {
$exif = exif_read_data($filename);
}

if ($image && $exif && isset($exif['Orientation'])) {
if ($image && isset($exif['Orientation']) == true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exif_read_data can return false, so assuming it is an array isn't a great idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you revert this, I can merge.

$ort = $exif['Orientation'];
} else {
return $image;
Expand Down