Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New error handling for unsupported image types #102

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions ps_imageslider.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,16 @@ protected function _postProcess()
} elseif (!$temp_name || !move_uploaded_file($_FILES['image_' . $language['id_lang']]['tmp_name'], $temp_name)) {
return false;
} elseif (!ImageManager::resize($temp_name, __DIR__ . '/images/' . $salt . '_' . $_FILES['image_' . $language['id_lang']]['name'], null, null, $type)) {
$errors[] = $this->displayError($this->trans('An error occurred during the image upload process.', [], 'Admin.Notifications.Error'));
$errors[] = $this->trans('An error occurred during the image upload process.', [], 'Admin.Notifications.Error');
}
if (file_exists($temp_name)) {
@unlink($temp_name);
}
$slide->image[$language['id_lang']] = $salt . '_' . $_FILES['image_' . $language['id_lang']]['name'];
} elseif (Tools::getValue('image_old_' . $language['id_lang']) != '') {
$slide->image[$language['id_lang']] = Tools::getValue('image_old_' . $language['id_lang']);
} else {
$errors[] = $this->trans('Image format not recognized, allowed formats are: jpg, gif, jpeg, png.', [], 'Admin.Notifications.Error');
}
}

Expand All @@ -504,10 +506,10 @@ protected function _postProcess()
/* Adds */
if (!Tools::getValue('id_slide')) {
if (!$slide->add()) {
$errors[] = $this->displayError($this->trans('The slide could not be added.', [], 'Modules.Imageslider.Admin'));
$errors[] = $this->trans('The slide could not be added.', [], 'Modules.Imageslider.Admin');
}
} elseif (!$slide->update()) {
$errors[] = $this->displayError($this->trans('The slide could not be updated.', [], 'Modules.Imageslider.Admin'));
$errors[] = $this->trans('The slide could not be updated.', [], 'Modules.Imageslider.Admin');
}
$this->clearCache();
}
Expand Down