You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
It's not possible to upload image using upload button in admin.
Preconditions:
Magento Version: 2.4.5-p7
Module Version: 2.11.6
PHP Version: 8.1
To Reproduce
Steps to reproduce the behavior:
Go to Magefan -> Posts page and add or edit any post.
Click on Upload button inside Display settings section
Select a valid image (png, jpg)
See error
Expected behavior
Image is uploaded and visible when saved
Actual behavior
Error message is shown: File validation failed
Screenshots
Additional context
I did a research about the issue and the problem is the \Magefan\Blog\Model\ImageUploader class is overriding \Magento\Catalog\Model\ImageUploader but is missing two variables in constructor (only $allowedMimeTypes is relevant for this isse)
to fix, I changed the constructor like this:
public function __construct(
\Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase,
\Magento\Framework\Filesystem $filesystem,
\Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Psr\Log\LoggerInterface $logger,
$baseTmpPath,
$basePath,
$allowedExtensions,
array $allowedMimeTypes = [], //added missing variable
Name $fileNameLookup = null //added missing variable
) {
parent::__construct(
$coreFileStorageDatabase,
$filesystem,
$uploaderFactory,
$storeManager,
$logger,
$baseTmpPath,
$basePath,
$allowedExtensions,
$allowedMimeTypes, //added to parent class constructor
$fileNameLookup //added to parent class constructor
);
$this->filesystem = $filesystem;
}
Then, I added the allowed mime types in di for this class:
Maybe you have some third-party extension that modifies allowedMimeTypes for Magefan\Blog\Model\ImageUploader ? Or Magento\Catalog\Model\ImageUploader
The problem that we cannot add allowedMimeTypes to our extension yet, as we currently still provide support for Magento 2.3.0 which does not have this property. Once we stop supporting it we will be able to add this modification.
Describe the bug
It's not possible to upload image using upload button in admin.
Preconditions:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Image is uploaded and visible when saved
Actual behavior
Error message is shown: File validation failed
Screenshots
Additional context
I did a research about the issue and the problem is the \Magefan\Blog\Model\ImageUploader class is overriding \Magento\Catalog\Model\ImageUploader but is missing two variables in constructor (only $allowedMimeTypes is relevant for this isse)
to fix, I changed the constructor like this:
Then, I added the allowed mime types in di for this class:
The text was updated successfully, but these errors were encountered: