I have system.xml with some fields:

<field id="image_width" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Image width</label>
<field id="image_height" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Image height</label>
<field id="placeholder_image" translate="label comment" type="image" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Image placeholder</label>
    <comment>Allowed file types:PNG, GIF, JPG, JPEG, SVG.</comment>
    <base_url type="media" scope_info="1">module_folder</base_url>

And i set default values for them in config.xml:


The problem is in placeholder_image field. My placeholder image lies in app/code/MyNamespace/MyModule/view/frontend/web/images/placeholder.gif and Magento 2 looks for it in pub/media/module_folder/placeholder.gif. How can i tell magento to copy it from my folder to pub/media?

1 Answer 1


I assume you have this code in one of your custom extensions.
You can use the Setup/InstallData.php or Setup/UpgradeData.php files that run when you install or upgrade the module and place an image inside the folder you need.

  • OP wants to set default values via module configxml
    – MagePsycho
    Jan 21, 2016 at 9:19
  • @MagePsycho. Yep. And this would work. Set the default value in config.xml then use the install/upgrade scripts to place that specific image into the desired folder.
    – Marius
    Jan 21, 2016 at 9:22
  • I think this is the only solution for now, so i accept it, but it would be great to have possibility to use something like <placeholder_image>Namespace_ModuleName::placeholder.gif</placeholder_image> in config.xml. Jan 28, 2016 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.