cancel
Showing results for 
Search instead for 
Did you mean: 

Custom image upload field on cms page

Custom image upload field on cms page

I've tried to set up an image uploader field on one of our cms pages but I can't seem to get it to save anything other than "Array" once the image is uploaded, which is an invalid value, so it hides the field. I tried to reuse as much as I could from the Category image uploader field to get it to work.

 

Why might it be saving this value and how can I work around it?

 

<field name="meta_og_image" formElement="imageUploader">
  <backend_model>Magento\Config\Model\Config\Backend\Image</backend_model>
  <settings>
	<elementTmpl>ui/form/element/uploader/image</elementTmpl>
	<notice translate="true">Please upload a pre-optimized image for Open Graph images.</notice>
	<label translate="true">Open Graph Image</label>
	<visible>true</visible>
	<required>false</required>
	<componentType>imageUploader</componentType>
	<dataType>Magento\Ui\Component\Element\DataType\Media\Image</dataType>
  </settings>
  <formElements>
	<imageUploader>
	  <settings>
		<uploaderConfig>
		  <param xsi:type="url" name="url" path="catalog/category_image/upload"/>
		</uploaderConfig>
		<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
		<openDialogTitle>Media Gallery</openDialogTitle>
		<allowedExtensions>jpg jpeg gif png</allowedExtensions>
		<maxFileSize>4194304</maxFileSize>
	  </settings>
	</imageUploader>
  </formElements>
</field>
1 REPLY 1

Re: Custom image upload field on cms page

Let's try follow this link.


@danrwallac70c0 wrote:

I've tried to set up an image uploader field on one of our cms pages but I can't seem to get it to save anything other than "Array" once the image is uploaded, which is an invalid value, so it hides the field. I tried to reuse as much as I could from the Category image uploader field to get it to work.

 

Why might it be saving this value and how can I work around it?

 

<field name="meta_og_image" formElement="imageUploader">
  <backend_model>Magento\Config\Model\Config\Backend\Image</backend_model>
  <settings>
	<elementTmpl>ui/form/element/uploader/image</elementTmpl>
	<notice translate="true">Please upload a pre-optimized image for Open Graph images.</notice>
	<label translate="true">Open Graph Image</label>
	<visible>true</visible>
	<required>false</required>
	<componentType>imageUploader</componentType>
	<dataType>Magento\Ui\Component\Element\DataType\Media\Image</dataType>
  </settings>
  <formElements>
	<imageUploader>
	  <settings>
		<uploaderConfig>
		  <param xsi:type="url" name="url" path="catalog/category_image/upload"/>
		</uploaderConfig>
		<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
		<openDialogTitle>Media Gallery</openDialogTitle>
		<allowedExtensions>jpg jpeg gif png</allowedExtensions>
		<maxFileSize>4194304</maxFileSize>
	  </settings>
	</imageUploader>
  </formElements>
</field>