I am trying to add a dynamic image field to my admin configuration tab, so far I have the field appearing but I can't save and or preview an uploaded image.
I can get this working fine with the static option from the system.xml using
<field id="imageupload" type="image" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>upload</label>
<backend_model>Magento\Config\Model\Config\Backend\Image</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">catalog/product/placeholder</upload_dir>
<base_url type="media" scope_info="1">catalog/product/placeholder</base_url>
</field>
However, I'm missing something when trying to replicate this in PHP, here is what I have so far
[
'id' => 'allergen' . $option->getValue(),
'type' => 'image',
'sortOrder' => ($index * 10),
'showInDefault' => '1',
'showInWebsite' => '0',
'showInStore' => '0',
'label' => 'Image for ' . $option->getLabel(),
'backend_model' => 'Magento\Config\Model\Config\Backend\Image',
'base_url' => ['value' => 'catalog/product/images', 'type'=>"media", 'scope_info'=>"1"],
'upload_dir' => ['value'=> 'catalog/product/images', 'config'=> "system/filesystem/media", 'scope_info'=>"1"],
'_elementType' => 'field',
'path' => '<sectionId>/<groupid>'
]
The image appears to be saving via the default backend model as text and not respecting the input image value