[-] BO : #PSTEST-705 fix scene image upload
This commit is contained in:
@@ -118,6 +118,10 @@ class SceneCore extends ObjectModel
|
|||||||
|
|
||||||
public function deleteImage()
|
public function deleteImage()
|
||||||
{
|
{
|
||||||
|
// Hack to prevent the main scene image from being deleted in AdminController::uploadImage() when a thumb image is uploaded
|
||||||
|
if (isset($_FILES['thumb']) && (!isset($_FILES['image']) || empty($_FILES['image']['name'])))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (parent::deleteImage())
|
if (parent::deleteImage())
|
||||||
{
|
{
|
||||||
if (file_exists($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format)
|
if (file_exists($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format)
|
||||||
|
|||||||
@@ -69,15 +69,17 @@ class AdminScenesControllerCore extends AdminController
|
|||||||
/* Generate image with differents size */
|
/* Generate image with differents size */
|
||||||
if (!($obj = $this->loadObject(true)))
|
if (!($obj = $this->loadObject(true)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ($obj->id && (isset($_FILES['image']) || isset($_FILES['thumb'])))
|
if ($obj->id && (isset($_FILES['image']) || isset($_FILES['thumb'])))
|
||||||
{
|
{
|
||||||
|
$base_img_path = _PS_SCENE_IMG_DIR_.$obj->id.'.jpg';
|
||||||
$images_types = ImageType::getImagesTypes('scenes');
|
$images_types = ImageType::getImagesTypes('scenes');
|
||||||
|
|
||||||
foreach ($images_types as $k => $image_type)
|
foreach ($images_types as $k => $image_type)
|
||||||
{
|
{
|
||||||
if ($image_type['name'] == 'large_scene' && isset($_FILES['image']))
|
if ($image_type['name'] == 'large_scene' && isset($_FILES['image']))
|
||||||
ImageManager::resize(
|
ImageManager::resize(
|
||||||
$_FILES['image']['tmp_name'],
|
$base_img_path,
|
||||||
_PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
|
_PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
|
||||||
(int)$image_type['width'],
|
(int)$image_type['width'],
|
||||||
(int)$image_type['height']
|
(int)$image_type['height']
|
||||||
@@ -85,11 +87,11 @@ class AdminScenesControllerCore extends AdminController
|
|||||||
else if ($image_type['name'] == 'thumb_scene')
|
else if ($image_type['name'] == 'thumb_scene')
|
||||||
{
|
{
|
||||||
if (isset($_FILES['thumb']) && !$_FILES['thumb']['error'])
|
if (isset($_FILES['thumb']) && !$_FILES['thumb']['error'])
|
||||||
$tmp_name = $_FILES['thumb']['tmp_name'];
|
$base_thumb_path = _PS_SCENE_THUMB_IMG_DIR_.$obj->id.'.jpg';
|
||||||
else
|
else
|
||||||
$tmp_name = $_FILES['image']['tmp_name'];
|
$base_thumb_path = $base_img_path;
|
||||||
ImageManager::resize(
|
ImageManager::resize(
|
||||||
$tmp_name,
|
$base_thumb_path,
|
||||||
_PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
|
_PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
|
||||||
(int)$image_type['width'],
|
(int)$image_type['width'],
|
||||||
(int)$image_type['height']
|
(int)$image_type['height']
|
||||||
|
|||||||
Reference in New Issue
Block a user