PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

upload an image then add it to the post automatically

  1. paulfrank
    Member

    I apologize if the question has already been asked and answered. I tried to search for similar questions/answers but the forum doesn't let me view replies so I'm afraid I have to ask (again). Is it possible to upload an image through GF, then have it automatically attach to the post, and most importantly have it go to a fixed location (e.g. top-left corner) in the post content? Basically, I'm looking at GF as a way to streamline the blog posting process for our not-very-computer-savvy writers. Thanks.

    Posted 14 years ago on Friday July 2, 2010 | Permalink
  2. While it is possible to have an image upload be attached automatically to the post (it is added to the gallery for the post that is created), it isn't currently a feature to have it automatically appear in the post content. This can be accompolished by using the available API hooks and writing some custom PHP.

    We do have plans for adding the ability to completely control the post body in an upcoming release. We will enable you to use form field variables in the post body so you can output ANY form field value in the post body, including non-post form fields and images. This is going to make the post creation capabilities much more powerful. This won't be in the next release that we are wrapping up now but will be in the release after that.

    Posted 14 years ago on Friday July 2, 2010 | Permalink
  3. vandelay
    Member

    I have a use for the same feature, so I will be looking forward to that future release.

    Posted 14 years ago on Friday July 2, 2010 | Permalink
  4. Strada
    Member

    In response to Carl:
    "This can be accompolished by using the available API hooks and writing some custom PHP. "

    Can you give an example of the use of those API hooks?
    This could be the answer I am looking for: in this thread

    I found the documentation about hooks and filters, but it is not comprehensive is it ?
    --
    Erwan

    Posted 14 years ago on Tuesday July 13, 2010 | Permalink
  5. drewbaker
    Member

    Hello PaulFrank,
    To answer your question, don't buy Gravity Forms.

    What your describing is a feature a lot of people want. Personally, I think GF has some misleading information on their features page in relation to the way images are handled, it's certainly not a feature as much as a beta feature.

    GF will not automatically insert an image into a post. The PHP and API calls Carl Hancock is talking about are way above the technical knowledge of most people. He has been talking about this feature "coming soon" for at least 5 months now, so don't hold your breath.
    http://forum.gravityhelp.com/topic/post-attachments-premium-add-ons#post-3134

    Of course they want you to buy this software, so they will say it's possible, but what he means to say is "If you can code PHP and know our plugin's code, then you can do it". But if you could code PHP, you probably wouldn't be buying this plugin would you?

    What you can do, is have a user upload 1 image per input button, and then you'd have to manually go into the post using Wordpress and place the image in the post. If you want to do multiple image uploading, you'd need to give the user multiple image upload buttons (so 10 uploads would require 10 buttons on the page). Like I said, it's not really a flushed out feature.

    If you can wait for the "future release" then I'd do that.

    Posted 14 years ago on Tuesday July 20, 2010 | Permalink
  6. @drewbaker

    I totally disagree that the information on the Gravity Forms site is misleading by any means. Also, this pre-sale question forum exists entirely to answer questions and provide clarification for potential Gravity Forms customers. You could have asked questions here before your purchase if you wanted to and we would have gladly helped clear things up for you.

    We absolutely don't have any desire or need to mislead people simply to make a sale as you've implied. We would rather have well-informed, happy customers.

    The site states that you can upload images to a post. The fact is that you can upload photos and they WILL be added to the media gallery for that page/post. If you simply wanted to show the photos in a gallery format, you could do so by using the built in gallery function in the post body. If you're creative, you can style the gallery itself for different layouts or limit the display to a single image and not have to manually add images.

    example screenshot

    http://forum.gravityhelp.com/topic/using-form-to-submit-blog-data#post-1822

    The site never states that there is currently any advanced post templating features or implies that advanced layouts are fully automated.

    Gravity Forms makes it easy for users to upload an image when creating a post via a user submitted form. Great for user submitted articles, directory sites, etc.

    Yes, if you have a good understanding of PHP, you can do some of this yourself now with the existing hooks and filters and for the record, we have many accomplished programmers among our clients not in small part because they recognize the amount of work that's gone into the product.

    That said, we know that people want more advanced options built into the UI and we're actively working on post templating functionality. Yes, people have been asking for it since day one, as with many other features like multi-page forms, etc. but the fact is it takes time to get these things built properly and some will naturally take priority over others. Gravity Forms still isn't a year old yet so we've come a long way, but still have tons of features we want to add.

    The fact is, the plugin does what we say it does and we stand behind that.

    It's apparent you've been waiting for the feature, and I can assure you that I've seen it and it's coming down the pipe very soon but you're going to have to continue to be patient.

    --------------------------------------------------------------------------------------------

    @paulfrank

    If you wanted to display just one image, for now, you could use something like this to grab the image from the post gallery, then display it in your post template wherever you would like.

    http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it

    Again, more advanced functionality IS on it's way, but depending on your needs, you still have some options to get it done.

    --------------------------------------------------------------------------------------------

    @Strada

    We're going to roll out an entirely new documentation section in the next couple of weeks. Alex has already documented all of the hooks and filters very thoroughly for this new wiki and I'm sure you and many others will find it very helpful. We still have some sections to finish, but it's nearing completion and we'll get it all published asap.

    Posted 14 years ago on Tuesday July 20, 2010 | Permalink
  7. Hi Kevin,

    let me add one more thing regarding your link 'Using Form to submit blog data' and how to include an uploaded image.

    Just in case that you don't want to include a single image as a gallery, you can use the following code:

    add_action("gform_post_submission", "post_submission_handler");
    function post_submission_handler($entry){
    
    	$post_id = $entry[ 'post_id' ]; 
    
    	$imagepost = get_post($post_id);
    
    	$arrImages  =& get_children('post_type=attachment&post_mime_type=image&post_parent='  . $post_id );
    
    	$arrKeys = array_keys($arrImages);
    
    	$objectID = $arrImages[$arrKeys['0']]->ID;
    
    	$imageObject = wp_get_attachment_image_src( $objectID, 'large' );
    
    	$originalContent = $imagepost->post_content;
    
    	$imagepost->post_content = '<img src="' . $imageObject[ 0 ] . '" alt="' . $imagepost->post_title . '" class="whatsoever" />' . $originalContent;
    
    	wp_update_post( $imagepost );
    }

    Chris

    Posted 14 years ago on Thursday July 22, 2010 | Permalink
  8. Nice. Thanks Chris.

    Posted 14 years ago on Thursday July 22, 2010 | Permalink
  9. gwc_wd
    Member

    Chris Grossmann: Your code works perfectly and can be added to custom.php in wp-content to avoid theme upgrade issues.

    Thank you for the code!

    Posted 14 years ago on Sunday September 5, 2010 | Permalink
  10. Strada
    Member

    Thanks guys !
    The last update made it possible for us to add an image to a post created from the form.
    you guys know how to keep your promises.
    Thank you very much !
    --
    Erwan

    Posted 14 years ago on Thursday September 23, 2010 | Permalink
  11. tomkinsong
    Member

    I've just this minute purchased GF and need this functionality. I was about to go the php code route but the last poster stated that the image can be placed in the content when the form is filled. Am I misunderstanding that?

    Thanks, Gary

    Posted 14 years ago on Friday September 24, 2010 | Permalink
  12. You can do this as an option on the Post Body field.

    - Edit the Post Body Field
    - Check the "Create post content template" checkbox

    This will then show a textarea with a form field variable drop down. In this textarea is where you use HTML and form field variables to pre-define how the Post Body should be created.

    Form field variables are replaced by the field value when the form is submitted. So if you have a Post Image on your form, you can insert the variable for that Post Image field and then when the post is created it will be inserted.

    This allows you to create a content template for the Post Body.

    Just keep in mind when using the post body content template that you need to insert the variable for the Post Body field itself for that content to be included.

    Posted 14 years ago on Friday September 24, 2010 | Permalink
  13. tomkinsong
    Member

    Ah okay, that worked - sorta! I'm having promlems with it applying the image as a thumbnail. I'm using the following in the Post Body field:

    {Description:3}

    {{Post Image:6}:thumbnail:left}

    Description works just fine and I do get the image but like I said, it's not displayed as a thumb. Instead, I get the image displayed at 640x480 and it has an open bracket to the left and :thumbnail:left} on the right. It's like it's ignoring everything except the {Post Image:6} part of the variable.

    Posted 14 years ago on Saturday September 25, 2010 | Permalink
  14. Looks like there could be a bug with the Post Image variable in the drop down. Here is what you can do to get it working.

    Change this:

    {{Post Image:6}:thumbnail:left}

    To this:

    {Post Image:6:thumbnail:left}

    That should do the trick. We will look at why this is happening and get it fixed in the next release.

    Posted 14 years ago on Saturday September 25, 2010 | Permalink
  15. tomkinsong
    Member

    Thanks Carl, that worked. I did need the thumb to be clickable though and to be linked to the full sized image, the way WP natively treats images. Is this possible?

    Posted 14 years ago on Saturday September 25, 2010 | Permalink
  16. By default it does not output any links, only the image. However we are going to add the ability to output just the fullpath to the image for whatever size you want... we won't be able to do this until the beginning of next week but we will go ahead and add this capability and then release an update.

    Posted 14 years ago on Saturday September 25, 2010 | Permalink
  17. tomkinsong
    Member

    Thanks Carl. I can do what I need with a very small mod to the post. For what I'm doing, I have to modify the post slightly anyways but this works.

    Posted 14 years ago on Saturday September 25, 2010 | Permalink
  18. Well, I bought this plugin because it was just about the only user-contributed content form that allowed image upload. I didn't read the fine print. So now I have to teach my client how to get the image (via URL or Media library) that is uploaded when the user submits a post and then manually add it to the post. GF was praised and recommended in a number of places and nowhere id I see an indication that image upload would involve a multiple step process. And I agree with drewbaker above that we've been hearing about this basic feature coming for what is now about 8 months.

    I don't mean to be rude, or to suggest that someone not buy this. But I think that either the image upload info should be put up front under "Features", or this basic faeture should be added now, or that the price should be lowered unitl this feature is in the plugin.

    I have not execrcised all of the GF capabilities, and I hope they work, but my confidence is diminished by this image upload issue.

    Posted 14 years ago on Wednesday November 3, 2010 | Permalink
  19. @SparklingDawg I'm not sure what exactly your issue is. Have you read all of this thread? Because it appears you have not.

    Start here:

    http://forum.gravityhelp.com/topic/upload-an-image-then-add-it-to-the-post-automatically#post-10336

    You don't need to manually insert the image from the media library into the post. But it's also not going to just automatically do this... you need to tell it to and where to place the images using the Post Body Content Template feature to automatically format your Post Body and insert the image that is uploaded into the content of the post.

    The few posts above this one explain how to do this using the Post Content Template options that exist on the Post Body field.

    We can't automatically add images to the post body. We wouldn't know 1) Where they should go in the Post Body in relation to the content and 2) What markup should be used as users have different preferences, etc. That is why we created the Post Content Template feature that allows you to have complete control over the Post Body content that is created, insert images and other form field values, control the markup, etc.

    Posted 14 years ago on Wednesday November 3, 2010 | Permalink
  20. Okay. I have to eat some crow.

    This modification to the Post Body as described by Carl doesthe trick:
    -------------
    You can do this as an option on the Post Body field.

    - Edit the Post Body Field
    - Check the "Create post content template" checkbox

    This will then show a textarea with a form field variable drop down. In this textarea is where you use HTML and form field variables to pre-define how the Post Body should be created.

    Form field variables are replaced by the field value when the form is submitted. So if you have a Post Image on your form, you can insert the variable for that Post Image field and then when the post is created it will be inserted.
    ---------

    Feel free to delete both of my comments.

    Problem solved. Now my client doesn't have to fuss with this.

    Posted 14 years ago on Wednesday November 3, 2010 | Permalink

This topic has been resolved and has been closed to new replies.