Skip to content

Conversation

@cap340
Copy link

@cap340 cap340 commented Jul 29, 2025

Questions Answers
Description? The namespace of class ImageOptimizationException has changed since version 1.7.8
Type? bug fix
BC breaks? class namespace
Deprecations? no
Fixed ticket?
Sponsor company
How to test? Clone this sample module into the /modules folder of a Prestashop version 1.7.8 or higher, your IDE will indicate Undefined type 'PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException'

What this change is about

The namespace of class ImageOptimizationException has changed since version 1.7.8
This class is used to throw an exception when resizing, cutting or optimizing image fails in the uploadFromTemp function.

  • version 1.7.7 and earlier
    use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException;
  • since version 1.7.8
    use Prestashop\Prestashop\Core\Image\Exception\ImageOptimizationException;
+ use Prestashop\Prestashop\Core\Image\Exception\ImageOptimizationException;
- use Prestashop\Prestashop\Core\Image\Uploader\Exception\ImageOptimizationException;
use Prestashop\Prestashop\Core\Image\Exception\ImageOptimizationException;

class SupplierExtraImageUploader implements ImageUploaderInterface
{
    /**
     * Uploads resized image from temporary folder to image destination
     *
     * @throws ImageOptimizationException
     * @throws MemoryLimitException
     */
    protected function uploadFromTemp(string $temporaryImageName, string $destination): void
    {
        if (!\ImageManager::checkImageMemoryLimit($temporaryImageName)) {
            throw new MemoryLimitException('Cannot upload image due to memory restrictions');
        }

        if (!\ImageManager::resize($temporaryImageName, $destination)) {
            throw new ImageOptimizationException('An error occurred while uploading the image. Check your directory permissions.');
        }

        unlink($temporaryImageName);
    }

The namespace of class ImageOptimizationException has changed since version 1.7.8

Move form:
PrestaShop\PrestaShop\Core\Image\Uploader\Exception
To:
Prestashop\Prestashop\Core\Image\Exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant