Skip to content

Commit

Permalink
Merge pull request #112 from Codencode/fix-ps_imageslider-Images-with…
Browse files Browse the repository at this point in the history
…-invalid-name-are-saved-but-not-displaying-correctly-37452
  • Loading branch information
boherm authored Dec 10, 2024
2 parents a6f6125 + 0b78fa9 commit 48ff741
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ps_imageslider.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,17 +514,18 @@ protected function _postProcess()
) {
$temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
$salt = sha1(microtime());
$file_name = Tools::str2url($_FILES['image_' . $language['id_lang']]['name']) . $type;
if ($error = ImageManager::validateUpload($_FILES['image_' . $language['id_lang']])) {
$errors[] = $error;
} 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)) {
} elseif (!ImageManager::resize($temp_name, __DIR__ . '/images/' . $salt . '_' . $file_name, null, null, $type)) {
$errors[] = $this->displayError($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'];
$slide->image[$language['id_lang']] = $salt . '_' . $file_name;
} elseif (Tools::getValue('image_old_' . $language['id_lang']) != '') {
$slide->image[$language['id_lang']] = Tools::getValue('image_old_' . $language['id_lang']);
}
Expand Down

0 comments on commit 48ff741

Please sign in to comment.