21

I found this issue when I had extended and created my own theme for the admin area. These buttons use FLASH. So if your browser does not support flash - then they will not appear. Ensure that the app/design/adminhtml/default/default/template/media folder exists and that there are 2 files within it. editor.phtml uploader.phtml Ensure that the skin/...


20

You can check in details by click, Resize Custom Image in Magento 2 Inside Block file keep below code, protected $_filesystem ; protected $_imageFactory; public function __construct( \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Image\AdapterFactory $imageFactory ) { ...


19

Solved This error can be caused by several server configuration issues. Each error will always present itself with the same generic warning from Magento 2: Attention: We don't recognize or support this file extension type. If your using Magento 2.2.0+ the error may be worded differently. Below are the most common server settings that are causing this error. ...


18

You need to create a class to handle your image upload field and show the image once is uploaded. So create [Namespace]\[Module]\Block\Adminhtml\[Entity]\Helper\Image class <?php namespace [Namespace]\[Module]\Block\Adminhtml\[Entity]\Helper; use Magento\Framework\Data\Form\Element\Image as ImageField; use Magento\Framework\Data\Form\Element\Factory ...


17

The accepted answer doesn’t consider caching the image to improve performance. You don’t need to resize and overwrite the image every time it’s requested. The following approach saves the resized image to a "cache" folder so successive calls return the image from the cache. The method is contained on a helper (not a block) so you can call it from any ...


16

In your project open the file lib/Varien/File/Uploader.php and put a Mage::log() inside the save() function. public function save($destinationFolder, $newFileName = null) { $this->_validateFile(); if ($this->_allowCreateFolders) { $this->_createDestinationFolder($destinationFolder); } if (!is_writable($destinationFolder)) ...


14

Actually Firefox stopped supporting Flash (http://www.computerworld.com/article/2948012/security/adobe-flash-must-die-firefox-facebook-itbwcw.html) Tobias Renger already made a no-flash uploader you get can from Github which works well. https://github.com/openstream/No-Flash-Image-Uploader


14

In system.xml you should add this code below: <field id="upload_image_id" translate="label comment" type="image" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Select Image</label> <backend_model>NameSpace\YourModule\Model\Config\Backend\Image</backend_model> <base_url type="media" ...


14

First you have to create your own module to override the save action and dataProvider for cms page. If you don't know how to create module Please refer this link http://inchoo.net/magento-2/how-to-create-a-basic-module-in-magento-2/. After creating a module, follow the following steps: Step 1. Add column for custom image on cms_page table Create ...


13

you have to pass pass image array that contain image url,name for passing it to ui component you can use dataprovider <argument name="class" xsi:type="string">Namespace\Modulen\Model\Modelname\DataProvider</argument> pass array like below. $categoryData['image'][0]['name'] = $category->getData('image'); $categoryData['...


12

Issue: This seems to be a conflict between your selection of the tmp folder and the folders Magento considers secure for being used as tmp. This can be observed in the validateFieldId() function in the class Magento\Framework\File\Uploader [0] => string(15) "C:\WINDOWS\TEMP" <for windows and probably var/tmp for unix based systems> [1] => ...


11

Using a simple function, you can use to get the image name after upload the image: $uploader->getUploadedFileName();


10

If you want to upload product image using rest api. You need to pass below parameters in your request. Your media upload url - http://127.0.0.1/megento2/index.php/rest/V1/products/{sku}/media. Method name - Post Below are the body parameters : [ { "id": 0, "media_type": "test", "label": "test", "position": 0, "disabled": true, "...


9

I've had this problem before. Magento uses Flash to display the Upload buttons. Go here and click the Check Now button to check your flash installation or try with a different browser that may have flash properly installed.


9

Either set keepFrame to true, so it's always exact 160x210, or set keepAspectRatio to false. Now it is making sure both width and height won't exceed the values you feed it. But since you don't want a frame, and want to keep your aspect ratio, it has to change both width and height in the same ratio. <?php echo $this->helper('catalog/image')->...


9

First, you should be add input type file at form and also add enctype='multipart/form-data' and <!-- --> <div class="field image"> <label class="label" for="image"><span><?php /* @escapeNotVerified */ echo __('Image') ?></span></label> <div class="control"> <input ...


9

The reason SVG's are disabled in Magento 2 by default, is for security reasons such as stored XSS. And I would recommend that you leave them disabled atleast for now until we get better sanitization for them. You can see an example of this in APPSEC-1673, where they removed SVGs in the favicon https://magento.com/security/patches/magento-2016-and-219-...


8

As stated by Qaisar, the idea is to use the data provider to add those information to the data. So in your form ui_component you first need to specify a data source: <dataSource name="faqs_form_data_source"> <argument name="dataProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Spacename\...


8

There are two ways to change max resizing width & height of the image after uploading: 1) Magento\Framework\File\Uploader.php contain constants MAX_IMAGE_HEIGHT & MAX_IMAGE_WIDTH which is set to 1200 by default 2) magento/module-backend/view/adminhtml/templates/media/uploader.phtml contains PHP code for echo same constants MAX_IMAGE_HEIGHT and ...


7

If you are using PHP 7 then go to lib/Varien/File/Uploader.php Find the following code $params['object']->$params['method']($this->_file['tmp_name']); And replace it with $params['object']->{$params['method']}($this->_file['tmp_name']);


7

Finally i got the answer I refer this module and implement in my custom module Find below useful code : following below steps 1) create layout.xml [vendor]/[module]/operation/view/adminhtml/layout/layout_edit.xml <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...


7

I had the same issue after patching 1.9.2.2 and 1.9.2.3. SUPEE-9767 adds an extended validate method in app/code/core/Mage/Core/Model/File/Validator/Image.php Mine was: public function validate($filePath) { $fileInfo = getimagesize($filePath); if (is_array($fileInfo) and isset($fileInfo[2])) { if ($this->isImageType($fileInfo[2])) { ...


6

As others have pointed out, the allowed image extensions are hard coded in core files. However, I found an observer that allows you to change them along with other configuration of the uploader: This goes into your config.xml <config> <adminhtml> <events> <catalog_product_gallery_prepare_layout> ...


6

bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] ) $pathname should be the server path to the file and not a url Try $path = Mage::getBaseDir('media') . DS; You should try using Varien_File_Uploader /* Starting upload */ $uploader = new Varien_File_Uploader('filename'); // Any extention would work $...


6

You Need to override core magento code here - here we have generated a custom module which will do this and override the core functionality - Namespace - "A2bizz" Generate below Directory Paths and their corresponding files and put the given code in it - /app/etc/modules/A2bizz_All.xml <config> <modules> <A2bizz_Adminhtml> ...


6

The Flash uploader has been replaced with a JS one. You only need to make sure you haven't missed the /js folder in the upgrade, and add this to your layout file Layout file url :/app/design/adminhtml/default/default/layout/aijko/widgetimagechooser.xml <reference name="head"> <action method="addJs"><file>lib/uploader/flow....


6

The Catalog model image uploader is a bit abstract. It can be used to upload images/files basically anywhere. It does not have a path and a tmp path set for image uploading. You can create a virtual type based on it and use that one. You can do that by adding this in the di.xml file of your module. <virtualType name="[entity]ImageUploader" type="...


6

The method $uploader->save($target); has a second parameter: string $newFileName Also you'll find the method $uploader->getUploadedFileName() to get the filename. You can use strpos() to find the string in the file name. I hope it helps you.


6

Add Below code in n _prepareForm() function inside app/code/Namespace/Module/Block/Adminhtml/Module/Edit/Tab/Main.php $fieldset->addField( 'profile', 'image', [ 'name' => 'profile', 'label' => __('Profile Image'), 'title' => __('Profile Image'), 'required' => false, 'disabled' => $...


6

Try this. Use javascript to add the class. $fieldset->addField( 'banner_image_mobile', 'image', [ 'name' => 'banner_image_mobile', 'label' => __('Mobile Banner Image'), 'title' => __('Mobile Banner Image'), 'note' => __('Size: 164px x 24px, Allowed File Types : (JPG,...


Only top voted, non community-wiki answers of a minimum length are eligible