how to upload image in post form?
-
Hi,
i’m doing my first steps with forminator (free) and the idea was to create a form for frontend posting.
Everything looked good but when creating a post, the editor doesn’t offer image upload/integration.
as the standard “post data” field offer only the “featured image” (don’t want to use that), i added an additional field to the form (file upload). It is shown in the form, i can select a picture, but after submission, its gone – not existing in media library, not shown in post.
then i realized that i can link an the “upload field” to “custom field” in the “Post Data” field….same behavior.
The files seem to be uploaded to the forminator folder correctly, but they are not show in the library and also not in the post.
Am i doing something wrong, or is there something special to consider?
Is it possible to change the editor – to one whichs offers upload, and ideally with sizing option and showing it with in the text?-
This topic was modified 1 year, 7 months ago by
hugofant.
-
This topic was modified 1 year, 7 months ago by
hugofant.
-
This topic was modified 1 year, 7 months ago by
hugofant.
The page I need help with: [log in to see the link]
-
This topic was modified 1 year, 7 months ago by
-
Hi @hugofant,
Hope this message finds you well.
Well, mapping or adding images to a Custom Post using Post Data Field, it doesn’t work, this issue has been previously reported, but, I am afraid we are unable to provide an ETA for the fix.
As workaround, if you are using ACF, our Second Line Support has created this mu-plugin as a temporal fix:
You need to update these lines:
Replace 4126, 2910 with your form IDs in this line:
$form_ids = array( 4126, 2910 ); //Please change form IDs to your form IDsReplace test_image with your Custom Field on this line:
if ( $post_val['key'] == 'test_image' ) { //Please change test_image to your custom field nameAbout the editor, is currently not possible either.
Let us know the results.
Best regards,
LauraHi,
We haven’t heard from you in a while, I’ll go and mark this thread as resolved. Note that you can still reply on this topic.
If you have any additional questions or require further help, please let us know!
Best regards,
LauraHi,
took some days, as i was not familiar with ACF.
in the meantime i’ve installed it and i think i understood the way it works.
I’ve also installed/activated the mu-plugin and entered my form ids and field name:$form_ids = array( 678 ); //Please change form IDs to your form IDsif ( $post_val['key'] == 'upload-1' ) { //Please change test_image to your custom field nameas this is not working, i’m not sure if this is the correct way to link them together.
A short description would be helpfull.
Thanks in advance and best regards
Hugofant-
This reply was modified 1 year, 7 months ago by
hugofant. Reason: additional info
two additional questions:
i’ve found your suggested solution here.
There’s written: its a bug and it’s expected to be fixed with one of nearest upcoming releases.
As this info is from Jan 20, 2023, more than a year in the past, has this bug still not been fixed?
and as there’s also written: “…and then put custom field name (may it be ACF or just regular custom field…” – do i really have to install/use ACF?
…and as there were already some releases in the meantime – is this “workaround” still working/up-to-date?
best regards
HugofantHi @hugofant
It seems there’s been some confusion here and I’m sorry about that. Let me address it:
1. the old ticket about the bug that you found – that’s not an issue. You can map uploaded images to custom fields.
The only “catch” here is that you must make sure about two requirements:
a) the “upload” field needs to be of “single” type and not multiple; if you want to add multiple images they need to have separate upload fields on the form, all set to “single” and they need to be mapped to separate custom fields
b) and “upload” field should have the option to store image in Media Library enabled in settings.
2. If you get that set, it’s pretty easy:
– enable “custom fields” option in “postdata” field
– put some label name in custom field “label”
– and select your upload field as custom field “value”And that’s it. Once you submit the form with image uploaded that image will be added as custom field.
You do not need ACF for that. WordPress supports simple custom fields out of the box.
However, since the images are added as custom fields’ values it’s up to you how to display them in post. They won’t be displayed automatically out of the box and displaying values of custom fields in front-end is not really related to Formiantor.
This can be done with a code in custom template file of the child theme, with a custom shortcode or using a free plugin like this one (or similar):
https://wordpress.org/plugins/shortcode-to-display-post-and-user-data/
Best regards,
AdamHi Adam,
i don’t understand.
I’ve the same request as described in the “bug”…you’ve sent me the same solution…
There’s written: its a bug and it’s expected to be fixed with one of nearest upcoming releases.
and also:
Due to the bug, this mapping is currently not passing URL from upload field to the mapped custom post and that’s why it’s not working for you.
So has it been fixed in the meantime and is it working now or not?
…and as you can see in my first post, i’ve already tried the way via custom field in the post data field:
then i realized that i can link an the “upload field” to “custom field” in the “Post Data” field….
Actually i’m using an “add post” form in Forminator. So my expectation is, when adding an “image upload” to the post data field (also via custom field), that the image will be displayed within the post afterwards…not on a specific position, but at least at the end of the post or as an “attachment”/link.
From my point of view it doesn’t make sense to upload an image when it will not be show afterwards.
So, simple question: Is it really not possible to display images in a post automatically, when creating post with the “add post” form of Forminator?
Can’t really believe this, as for example the plugin Postie can handle this without any problem…
Thanks and best regards
HugofantHi @hugofant
I’ve the same request as described in the “bug”…you’ve sent me the same solution…
There’s written: its a bug and it’s expected to be fixed with one of nearest upcoming releases.Bug was that upload fields could not be mapped to custom fields at all. This is no longer the case.
What was not possible directly (and still is not) is that those images can’t directly be injected into post content. That’s lack of the feature though, not a bug.
Due to the bug, this mapping is currently not passing URL from upload field to the mapped custom post and that’s why it’s not working for you.
So has it been fixed in the meantime and is it working now or not?Fixed.
that the image will be displayed within the post afterwards…not on a specific position, but at least at the end of the post or as an “attachment”/link.
From my point of view it doesn’t make sense to upload an image when it will not be show afterwards.I understand it but please note that how the post and its content, including custom fields, is displayed on site has literally nothing to do with Forminator. It’s strictly and only related to how your theme works (or theme and other plugins related to layout/design).
You can add upload field to the form. You can map it to custom field. This will save uploaded image URL in custom field. That’s it.
How you display the post and its data (including custom posts) doesn’t related on it.
—-
As I mentioned earlier, one of the simplest solution is to use the plugin that I suggested earlier and just put shortcode to display that custom field value in the post.
Hi Adam,
sorry to bother you again, but i’ve tested the suggested solution and there is still a problem.
The method generally works. i can see at least the pictures in the single post site but when looking into the media library the images are show as “unattached”. Think this will result i a big mess after a few months.
Is there a solution for that, or have i done something wrong?Hello Hugofant,
There’s currently no option to attach uploaded files to posts out of the box, but we have a feature request for the developers to consider implementing this. There’s no ETA though, I’m afraid.
In order to make sure that we understand your current setup correctly, could you please confirm, if you are using regular custom fields for the image paths, and not ACF?
You are using this plugin for displaying images – is that right?
We just need to confirm the above first, to check for possible workarounds.
Looking forward to your reply!Best Regards,
Dmytroyes, i’m using only Forminator (custom fields within the post data field) and the mentioned plugin.
best regards
HugofantHi @hugofant
Thanks for confirmation!
Images being “unattached” is actually expected in such case.
An “attached” image is an image that is a “featured image” or image that’s injected into post content. Custom field is just a, so to say, “db record” with some data and in general – images that are added to custom fields are not marked as “attached” by WordPress core.
They’d need to be specifically set to be attached by the code but since Forminator does not yet handle injecting images into posts (as mentioned by my colleague above), it is not happening. All it does is only putting data from the form field into the custom field.
Kind regards,
Adam -
This reply was modified 1 year, 7 months ago by
The topic ‘how to upload image in post form?’ is closed to new replies.